gojimmypi / imageConvert2BMP

initial working image conversion
1 stars 0 forks source link

I have a question #1

Open nodoubtman opened 3 years ago

nodoubtman commented 3 years ago

Hello. I have a question, is it possible to convert other image from other website...??

and how?

thanks. Marc.

gojimmypi commented 3 years ago

Hi & thanks for your question.

I haven't looked at this in a long time. It looks like what I wrote is supposed to accept etiher a local path or a url: you can specify the targetHttpImage QueryString parameter instead :

http://gojimmypi-dev-imageconvert2bmp.azurewebsites.net/default.aspx?targetHttpImage=raw.githubusercontent.com/gojimmypi/imageConvert2BMP/master/imageConvert2BMP/images/buspirate.png&newImageSizeY=240&newImageSizeX=320

but I was not able to get it to work on the azure site. It was so long ago - I cannot even find that on my azure account.

It does appear that the GitHub version may be newer than the azure example, as there's an example of targetHttpImage like this:

http://gojimmypi-dev-imageconvert2bmp.azurewebsites.net/default.aspx?newImageSizeX=80&targetHttpImage=http://ichef.bbci.co.uk/news/304/cpsprodpb/BC8A/production/_92466284_img-20161116-wa0085.jpg

Do you have someplace to host this? Perhaps I made that change and just never deployed it to the azure example. (which in free mode, stops working after a few conversions)

Further proof that the GitHub version is newer: the help has much more detail.

Also: Although the System.Drawing graphics library is rich with features, I wrote this app only to convert images to a bit-mapped .BMP file format.

nodoubtman commented 3 years ago

JUST AMAZING WORKING OUT OF THE BOX đź‘Ť LINK đź‘Ť

http://gojimmypi-test-imageconvert2bmp.azurewebsites.net/default.aspx?newImageSizeX=240&newImageSizeY=320&targetHttpImage=http://www.bijint.com/assets/pict/chiba/pc/1656.jpg

THANKS!!! :)

nodoubtman commented 3 years ago

Hello, it looks that your website is offline? :-(

gojimmypi commented 3 years ago

@nodoubtman erg. that's not cool. I checked my email, and there's no recent email from Microsoft about this. I seem to recall that it had limited usage in the free tier, so if someone would call it frequently it would shut down. But I think the web page would give a more intuitive message.

When is the last time it worked for you? Did you use it often?

Coincidentally, I received this at the day job just yesterday:

image I don't recall if I used my personal or work account for this imageConvert2BMP demo. Odd, as our enterprise licenses should not be expiring in May anyhow.

It has been online for years though. I'll check into it. Thanks for the heads up.

nodoubtman commented 3 years ago

Yes i use it often ... i use it with my esp32 to convert any image on my tft and web server.

Thank you. Marc.

Télécharger Outlook pour Androidhttps://aka.ms/ghei36


From: gojimmypi @.> Sent: Tuesday, May 18, 2021 11:23:48 AM To: gojimmypi/imageConvert2BMP @.> Cc: Marc Paradis @.>; Mention @.> Subject: Re: [gojimmypi/imageConvert2BMP] I have a question (#1)

@nodoubtmanhttps://github.com/nodoubtman erg. that's not cool. I checked my email, and there's no recent email from Microsoft about this. I seem to recall that it had limited usage in the free tier, so if someone would call it frequently it would shut down. But I think the web page would give a more intuitive message.

When is the last time it worked for you? Did you use it often?

Coincidentally, I received this at the day job just yesterday:

[image]https://user-images.githubusercontent.com/13059545/118678061-8b5aa500-b7b1-11eb-9a87-127ac9140896.png I don't recall if I used my personal or work account for this imageConvert2BMP demo. Odd, as our enterprise licenses should not be expiring in May anyhow.

It has been online for years though. I'll check into it. Thanks for the heads up.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/gojimmypi/imageConvert2BMP/issues/1#issuecomment-843266929, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZU2IZTJNIPF3DXZZN7SNLTOKBAJANCNFSM4UZG5DEQ.

nodoubtman commented 3 years ago

Error 403 This webapp is stopped.

Télécharger Outlook pour Androidhttps://aka.ms/ghei36


From: Marc Paradis @.> Sent: Tuesday, May 18, 2021 1:47:54 PM To: gojimmypi/imageConvert2BMP @.> Subject: Re: [gojimmypi/imageConvert2BMP] I have a question (#1)

Yes i use it often ... i use it with my esp32 to convert any image on my tft and web server.

Thank you. Marc.

Télécharger Outlook pour Androidhttps://aka.ms/ghei36


From: gojimmypi @.> Sent: Tuesday, May 18, 2021 11:23:48 AM To: gojimmypi/imageConvert2BMP @.> Cc: Marc Paradis @.>; Mention @.> Subject: Re: [gojimmypi/imageConvert2BMP] I have a question (#1)

@nodoubtmanhttps://github.com/nodoubtman erg. that's not cool. I checked my email, and there's no recent email from Microsoft about this. I seem to recall that it had limited usage in the free tier, so if someone would call it frequently it would shut down. But I think the web page would give a more intuitive message.

When is the last time it worked for you? Did you use it often?

Coincidentally, I received this at the day job just yesterday:

[image]https://user-images.githubusercontent.com/13059545/118678061-8b5aa500-b7b1-11eb-9a87-127ac9140896.png I don't recall if I used my personal or work account for this imageConvert2BMP demo. Odd, as our enterprise licenses should not be expiring in May anyhow.

It has been online for years though. I'll check into it. Thanks for the heads up.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/gojimmypi/imageConvert2BMP/issues/1#issuecomment-843266929, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZU2IZTJNIPF3DXZZN7SNLTOKBAJANCNFSM4UZG5DEQ.

nodoubtman commented 3 years ago

If u want me to contribute to have stoll access to this project i will.

Télécharger Outlook pour Androidhttps://aka.ms/ghei36


From: Marc Paradis @.> Sent: Tuesday, May 18, 2021 2:33:21 PM To: gojimmypi/imageConvert2BMP @.> Subject: Re: [gojimmypi/imageConvert2BMP] I have a question (#1)

Error 403 This webapp is stopped.

Télécharger Outlook pour Androidhttps://aka.ms/ghei36


From: Marc Paradis @.> Sent: Tuesday, May 18, 2021 1:47:54 PM To: gojimmypi/imageConvert2BMP @.> Subject: Re: [gojimmypi/imageConvert2BMP] I have a question (#1)

Yes i use it often ... i use it with my esp32 to convert any image on my tft and web server.

Thank you. Marc.

Télécharger Outlook pour Androidhttps://aka.ms/ghei36


From: gojimmypi @.> Sent: Tuesday, May 18, 2021 11:23:48 AM To: gojimmypi/imageConvert2BMP @.> Cc: Marc Paradis @.>; Mention @.> Subject: Re: [gojimmypi/imageConvert2BMP] I have a question (#1)

@nodoubtmanhttps://github.com/nodoubtman erg. that's not cool. I checked my email, and there's no recent email from Microsoft about this. I seem to recall that it had limited usage in the free tier, so if someone would call it frequently it would shut down. But I think the web page would give a more intuitive message.

When is the last time it worked for you? Did you use it often?

Coincidentally, I received this at the day job just yesterday:

[image]https://user-images.githubusercontent.com/13059545/118678061-8b5aa500-b7b1-11eb-9a87-127ac9140896.png I don't recall if I used my personal or work account for this imageConvert2BMP demo. Odd, as our enterprise licenses should not be expiring in May anyhow.

It has been online for years though. I'll check into it. Thanks for the heads up.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/gojimmypi/imageConvert2BMP/issues/1#issuecomment-843266929, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZU2IZTJNIPF3DXZZN7SNLTOKBAJANCNFSM4UZG5DEQ.

gojimmypi commented 3 years ago

It appears that I created this with my day job enterprise subscription that has long since expired. I have no idea why I received the message above that says it expires on May 17. My current enterprise subscription is also expiring soon (not this month), but I'm not sure what triggered the problem with the old one as it is supposed to be a free service. Really not cool to have things just disabled one day and then deleted, particularly if it was on the free tier. Ah, the joy of "cloud" solutions. :/

I could not find an easy way to migrate this to my current subscription, but I was able to publish to a new site here.

Thanks for the offer to contribute, but the day job does pay me a salary and keeping up on this kind of technology is part of that. I will say that there's no guarantee that this will continue working. Also, I believe on the free tier, there's a limit to how much the site can be accessed. Do you actually use the web conversion from an embedded device, or do you just need a one-time conversion? I could create a command-line app that in theory, should work on Mac / Linux / Windows using the new dotnet core technology.

In any case - thanks again for the heads up. I'm glad you found this useful. Let me know if the new site works for you.

nodoubtman commented 3 years ago

Hello Jimmypi! :o)

Thank you for the update... i use ESP32 to show it on the TFT.... can i host your program on my raspberry pi 3 and how?

Thanks. Marc.


De : gojimmypi @.> Envoyé : 18 mai 2021 23:34 À : gojimmypi/imageConvert2BMP @.> Cc : Marc Paradis @.>; Mention @.> Objet : Re: [gojimmypi/imageConvert2BMP] I have a question (#1)

It appears that I created this with my day job enterprise subscription that has long since expired. I have no idea why I received the message above that says it expires on May 17. My current enterprise subscription is also expiring soon (not this month), but I'm not sure what triggered the problem with the old one as it is supposed to be a free service. Really not cool to have things just disabled one day and then deleted, particularly if it was on the free tier. Ah, the joy of "cloud" solutions. :/

I could not find an easy way to migrate this to my current subscription, but I was able to publish to a new site herehttps://imageconvert2bmp20210518160938.azurewebsites.net/.

Thanks for the offer to contribute, but the day job does pay me a salary and keeping up on this kind of technology is part of that. I will say that there's no guarantee that this will continue working. Also, I believe on the free tier, there's a limit to how much the site can be accessed. Do you actually use the web conversion from an embedded device, or do you just need a one-time conversion? I could create a command-line app that in theory, should work on Mac / Linux / Windows using the new dotnet core technology.

In any case - thanks again for the heads up. I'm glad you found this useful. Let me know if the new site works for you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/gojimmypi/imageConvert2BMP/issues/1#issuecomment-843635039, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZU2I7XJO2IWWRE7DC2KVDTOL2PVANCNFSM4UZG5DEQ.

nodoubtman commented 3 years ago

It appears that I created this with my day job enterprise subscription that has long since expired. I have no idea why I received the message above that says it expires on May 17. My current enterprise subscription is also expiring soon (not this month), but I'm not sure what triggered the problem with the old one as it is supposed to be a free service. Really not cool to have things just disabled one day and then deleted, particularly if it was on the free tier. Ah, the joy of "cloud" solutions. :/

I could not find an easy way to migrate this to my current subscription, but I was able to publish to a new site here.

Thanks for the offer to contribute, but the day job does pay me a salary and keeping up on this kind of technology is part of that. I will say that there's no guarantee that this will continue working. Also, I believe on the free tier, there's a limit to how much the site can be accessed. Do you actually use the web conversion from an embedded device, or do you just need a one-time conversion? I could create a command-line app that in theory, should work on Mac / Linux / Windows using the new dotnet core technology.

In any case - thanks again for the heads up. I'm glad you found this useful. Let me know if the new site works for you.

Hey, it's seems i cannot connect to it, even with the azure cert i pass in getFileSpiffs with the ESP32 error: Unable to get album art: connection refused :(

URL: https://imageconvert2bmp20210518160938.azurewebsites.net?newImageSizeX=240&newImageSizeY=320&targetHttpImage=http://ichef.bbci.co.uk/news/304/cpsprodpb/BC8A/production/_92466284_img-20161116-wa0085.jpg

Here's my code:

// AZURE CERT const char* AZURE_CERT = "-----BEGIN CERTIFICATE-----\n" "MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BA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RLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n" "ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n" "R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n" "-----END CERTIFICATE-----";

// Fetch a file from the URL given and save it in SPIFFS // Return 1 if a web fetch was needed or 0 if file already exists bool getFileSPIFFS(String url, String filename) { static bool ok = false;

unsigned long started = millis();

// If it exists then no need to fetch it if (SPIFFS.exists(filename) == true) { Serial.println("Found " + filename); Serial.println(F("Removing file.")); SPIFFS.remove(filename); }

Serial.println("\nDownloading " + filename + " from " + url);

HTTPClient http;

// Check WiFi connection if ((WiFi.status() == WL_CONNECTED)) { Serial.print("\n[HTTP] Get File SPIFFs Begin...\n");

// Configure server and url
http.begin(url, AZURE_CERT);

Serial.print("\n[HTTP] GET... File SPIFFs Begin...\n");
// Start connection and send HTTP header
int httpCode = http.GET();
if (httpCode == HTTP_CODE_OK) {
  fs::File f = SPIFFS.open(filename, "w+");
  if (!f) {
    Serial.println(F("File open failed"));
    return false;
  }
  // HTTP header has been send and Server response header has been handled
  Serial.printf("\n[HTTP] GET... code: %d\n", httpCode);

  // File found at server
  if (httpCode == HTTP_CODE_OK) {

    // Get length of document (is -1 when Server sends no Content-Length header)
    int total = http.getSize();
    int len = total;

    // Create buffer for read
    uint8_t buff[128] = { 0 };

    // Get tcp stream
    WiFiClient * stream = http.getStreamPtr();

    // Read all data from server
    while (http.connected() && (len > 0 || len == -1)) {
      // Get available data size
      size_t size = stream->available();

      if (size) {
        // Read up to 128 bytes
        int c = stream->readBytes(buff, ((size > sizeof(buff)) ? sizeof(buff) : size));

        // Write it to file
        f.write(buff, c);

        // Calculate remaining bytes
        if (len > 0)
          len -= c;
      } //  while (http.connected() && (len > 0 || len == -1))
      yield();
    }
    Serial.println();
    Serial.print("\n[HTTP] connection closed or file end.\n");
  }  //  if (httpCode == HTTP_CODE_OK)

  f.close();
  ok = true;
}
else {
  Serial.printf("\n[HTTP] GET... Failed, Error: %s\n", http.errorToString(httpCode).c_str());
  ok = false;
}

}

if ( http.connected() ) http.end();

if (ok) { unsigned long finalTime = millis(); unsigned long totalTime = finalTime - started; Serial.print(F("Downloading took: ")); Serial.print(totalTime / 1000); Serial.println(F(" seconds.")); }

return ok; // File was fetched from web }

nodoubtman commented 3 years ago

Hello i have tried the new code but the connection is refused :-(

// http://imageconvert2bmp20210518160938.azurewebsites.net?newImageSizeX=240&newImageSizeY=320&targetHttpImage=https://thumbs.dreamstime.com/b/woman-dark-makeup-red-nails-26464018.jpg String Return_Formatted_URL(String url, int imageSizeX, int imageSizeY) { String apiGetData = ""; //apiGetData.reserve(108 + url.length() + 1); //apiGetData = "";

apiGetData += "https://imageconvert2bmp20210518160938.azurewebsites.net?newImageSizeX="; apiGetData += String(imageSizeX); apiGetData += "&newImageSizeY="; apiGetData += String(imageSizeY); apiGetData += "&targetHttpImage="; apiGetData += url; apiGetData.trim();

Serial.println(F("URL: ")); Serial.println(apiGetData);

return apiGetData; }

// Fetch a file from the URL given and save it in SPIFFS // Return 1 if a web fetch was needed or 0 if file already exists bool getFileSPIFFS(String url, String filename) { static bool ok = false;

unsigned long started = millis();

// If it exists then no need to fetch it if (SPIFFS.exists(filename) == true) { Serial.println("Found " + filename); Serial.println(F("Removing file.")); SPIFFS.remove(filename); }

Serial.println("\nDownloading " + filename + " from " + url);

HTTPClient http; WiFiClientSecure photoClientSecure;

http.useHTTP10(true); photoClientSecure.setCACert(AZURE_CERT);

// Check WiFi connection //if ((WiFi.status() == WL_CONNECTED)) { Serial.println("\n[HTTPs] Get File SPIFFs Begin...\n");

// Configure server and url //http.begin(photoClientSecure, url);

// https://imageconvert2bmp20210518160938.azurewebsites.net/

photoClientSecure.connect("imageconvert2bmp20210518160938.azurewebsites.net", 443); http.begin(photoClientSecure, url);

Serial.print("\n[HTTPs] GET... File SPIFFs Begin...\n"); // Start connection and send HTTP header int httpCode = http.GET(); if (httpCode == HTTP_CODE_OK) { fs::File f = SPIFFS.open(filename, "w+"); if (!f) { Serial.println(F("File open failed")); return false; } // HTTP header has been send and Server response header has been handled Serial.printf("\n[HTTPs] GET... File SPIFFs code: %d\n", httpCode);

// File found at server
if (httpCode == HTTP_CODE_OK) {

  // Get length of document (is -1 when Server sends no Content-Length header)
  int total = http.getSize();
  int len = total;

  // Create buffer for read
  uint8_t buff[128] = { 0 };

  // Get tcp stream
  WiFiClient * stream = http.getStreamPtr();

  // Read all data from server
  while (http.connected() && (len > 0 || len == -1)) {
    // Get available data size
    size_t size = stream->available();

    if (size) {
      // Read up to 128 bytes
      int c = stream->readBytes(buff, ((size > sizeof(buff)) ? sizeof(buff) : size));

      // Write it to file
      f.write(buff, c);

      // Calculate remaining bytes
      if (len > 0)
        len -= c;
    } //  while (http.connected() && (len > 0 || len == -1))
    yield();
  }
  Serial.println();
  Serial.print("\n[HTTP] File SPIFFs Connection Closed or file end.\n");
}  //  if (httpCode == HTTP_CODE_OK)

f.close();
ok = true;

} else { Serial.printf("\n[HTTP] GET... File SPIFFs Failed, Error: %s\n", http.errorToString(httpCode).c_str()); ok = false; } // }

if ( http.connected() ) http.end();

if (ok) { unsigned long finalTime = millis(); unsigned long totalTime = finalTime - started; Serial.print(F("Downloading took: ")); Serial.print(totalTime / 1000); Serial.println(F(" seconds.")); }

return ok; // File was fetched from web }

nodoubtman commented 3 years ago

Can you help?

gojimmypi commented 3 years ago

Sorry for the delay. Your link when opened in a browser seems to work for me. I have not tried using it from your specific code. How's it coming along for you?

nodoubtman commented 3 years ago

Working flawless, i just changed my code :-)

Thank you. Marc.

gojimmypi commented 3 years ago

that's excellent! congratulations. I'm glad you have it working :)

nodoubtman commented 3 years ago

A little question... why this url doesnt work:

https://imageconvert2bmp20210518160938.azurewebsites.net/?newImageSizeX=240&newImageSizeY=320&targetHttpImage=https://www.nasa.gov/sites/default/files/styles/full_width_feature/public/thumbnails/image/51238521674_3297226a3a_o.jpeg

also why does it takes 24 secs to download the actual image.. on your site? here's my code:

// Fetch a file from the URL given and save it in SPIFFS // Return 1 if a web fetch was needed or 0 if file already exists bool getFileSPIFFS(String myURi, String filename) { static bool ok = false;

unsigned long started = millis();

Serial.println("\nDownloading " + filename + " from " + myURi);

Serial.println("\n[HTTPs] Get File SPIFFs Begin...\n");

HTTPClient https; https.begin("imageconvert2bmp20210518160938.azurewebsites.net", 443, myURi, AZURE_CERT);

ifdef M5STACK

https.setUserAgent("ESP32-M5STACK");

else

https.setUserAgent("ESP32-LOLIN32");

endif

https.addHeader("Content-Type", "image/bmp");

// Start connection and send HTTP header int httpCode = https.GET(); if (httpCode == HTTP_CODE_OK) {

if ( SPIFFS.exists(filename) ) {
  Serial.printf("\nFile %s exists, Removing %s\n", filename.c_str(), filename.c_str());
  SPIFFS.remove(filename);
  vTaskDelay(1000 / portTICK_PERIOD_MS);
}  // if ( SPIFFS.exists(filename) )

fs::File f = SPIFFS.open(filename, "w+");
if (!f) {
  Serial.println(F("File open failed"));
  https.end();
  return false;
} // if (!f)

https.writeToStream(&f);
yield();
https.end();
yield();
f.close();

} // if (httpCode == HTTP_CODE_OK)

// HTTP header has been send and Server response header has been handled Serial.printf("\n[HTTPs] GET... File SPIFFs code: %d\n", httpCode);

unsigned long finalTime = millis(); unsigned long totalTime = finalTime - started; Serial.print(F("Downloading took: ")); Serial.print(totalTime / 1000); Serial.println(F(" seconds."));

ESPUI.print(secondeDownloadImageLabel, String(totalTime / 1000));

return true; }

can you help me ?

thank you. Marc.