Favicon

Galeforce9
Posts: 7
Joined: Thu Sep 10, 2020 8:22 pm

Favicon

Postby Galeforce9 » Sat Mar 26, 2022 6:44 pm

Hello,

I have tried for some time to get this to work without success. I simple want to serve a Favicon via the webserver.

I have multiple webpages all being served fine without an issue. This is the code I have but on loading a webpage I do not get the Favicon and if I go to the root and add /favicon.ico or .png I get a grey square but not the 16 x 16 icon image.

Code: Select all

  server.on("/favicon.ico", Fav);
  server.on("/favicon.png", Fav);

Code: Select all

void Fav() {
char Favicon[487] = {
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0xF3, 0xFF, 
0x61, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, 
0x01, 0xA1, 0x49, 0x44, 0x41, 0x54, 0x38, 0x4F, 0xAD, 0x93, 0x3F, 0x2C, 0x43, 0x61, 0x14, 0xC5, 
0x7F, 0x5F, 0xFF, 0xBE, 0xD7, 0xA2, 0x94, 0x36, 0x4D, 0x2C, 0x4D, 0x13, 0x0B, 0x62, 0x69, 0x52, 
0x89, 0xC5, 0x24, 0xDA, 0x4D, 0x84, 0xC9, 0x68, 0x6A, 0xBB, 0x59, 0x89, 0x10, 0x91, 0x20, 0x11, 
0x53, 0x0D, 0xB4, 0x4B, 0x07, 0x1B, 0x1B, 0x9B, 0x88, 0x81, 0x68, 0x6A, 0x23, 0x31, 0x34, 0x16, 
0xFF, 0x87, 0x26, 0x5E, 0xD2, 0xE2, 0xB5, 0xF4, 0x3D, 0x79, 0x4F, 0x54, 0x2C, 0x92, 0xE2, 0xAE, 
0xDF, 0xB9, 0xE7, 0xDC, 0x73, 0xBE, 0x7B, 0x45, 0x30, 0x18, 0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22, 
0x11, 0x95, 0x87, 0x07, 0x2B, 0xDB, 0xDB, 0xCD, 0x75, 0x82, 0xCD, 0x4D, 0x0F, 0xFB, 0xFB, 0x6E, 
0x26, 0x27, 0x15, 0x86, 0x86, 0x9E, 0x91, 0x65, 0x8D, 0xDE, 0xDE, 0x2A, 0x47, 0x47, 0xF2, 0x97, 
0x05, 0xC3, 0xD3, 0xDD, 0x9D, 0x95, 0xB1, 0xB1, 0x32, 0x1B, 0x1B, 0x1E, 0x3A, 0x3A, 0x6A, 0xA6, 
0xCA, 0xC1, 0x81, 0x8B, 0xE5, 0x65, 0x2F, 0x85, 0x82, 0x83, 0xF9, 0xF9, 0x22, 0xAA, 0x2A, 0x18, 
0x1C, 0x7C, 0xA1, 0xAB, 0xAB, 0xCA, 0xDA, 0x5A, 0x1B, 0x66, 0x88, 0x0B, 0x0B, 0x45, 0x62, 0xB1, 
0x27, 0x24, 0x49, 0x37, 0xD5, 0x97, 0x96, 0xDA, 0x49, 0x24, 0x1E, 0xF1, 0xFB, 0x3F, 0x42, 0x34, 
0xAC, 0xAD, 0xAE, 0x7A, 0xC9, 0x66, 0xEF, 0x19, 0x18, 0x78, 0xE1, 0xF5, 0x55, 0xB0, 0xBB, 0xEB, 
0x66, 0x66, 0xC6, 0x47, 0x7D, 0x0F, 0x8C, 0x84, 0x6D, 0x36, 0xDD, 0x7C, 0xFC, 0xA9, 0xAC, 0x56, 
0xDD, 0xFC, 0x6A, 0x4D, 0xFB, 0xC0, 0xFD, 0xEF, 0x22, 0xFD, 0x66, 0xA5, 0xFF, 0x7E, 0x4C, 0x7F, 
0x3D, 0xE7, 0x77, 0x1D, 0x9D, 0xB1, 0x7A, 0xAB, 0xAA, 0x55, 0x9D, 0x00, 0x00, 0x00, 0x00, 0x49, 
0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82  };

  server.send(200, "image/png", Favicon);
}
Any advice gladly accepted.

Thank you

Ian

ESP_Sprite
Posts: 9725
Joined: Thu Nov 26, 2015 4:08 am

Re: Favicon

Postby ESP_Sprite » Sun Mar 27, 2022 1:13 am

Your favicon is binary content, you can't send it as a string.
https://github.com/me-no-dev/ESPAsyncWe ... om-progmem

Galeforce9
Posts: 7
Joined: Thu Sep 10, 2020 8:22 pm

Re: Favicon

Postby Galeforce9 » Sun Mar 27, 2022 9:49 am

Hello,

Thank you for the reply. I had searched for a correct solution but could not find the answer. I am not using the async server but the built in webserver.h so could not use the example as shown.

I changed the table to int8 and then converted to a string to feed to server.send as I do not know any other way to reply to the server request. Changed code below but still does not work.

Code: Select all

void Fav() {
uint8_t Favicon[487] = {
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0xF3, 0xFF, 
0x61, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, 
0x01, 0xA1, 0x49, 0x44, 0x41, 0x54, 0x38, 0x4F, 0xAD, 0x93, 0x3F, 0x2C, 0x43, 0x61, 0x14, 0xC5, 
0x7F, 0x5F, 0xFF, 0xBE, 0xD7, 0xA2, 0x94, 0x36, 0x4D, 0x2C, 0x4D, 0x13, 0x0B, 0x62, 0x69, 0x52, 
0x89, 0xC5, 0x24, 0xDA, 0x4D, 0x84, 0xC9, 0x68, 0x6A, 0xBB, 0x59, 0x89, 0x10, 0x91, 0x20, 0x11, 
0x53, 0x0D, 0xB4, 0x4B, 0x07, 0x1B, 0x1B, 0x9B, 0x88, 0x81, 0x68, 0x6A, 0x23, 0x31, 0x34, 0x16, 
0xFF, 0x87, 0x26, 0x5E, 0xD2, 0xE2, 0xB5, 0xF4, 0x3D, 0x79, 0x4F, 0x54, 0x2C, 0x92, 0xE2, 0xAE, 
0xDF, 0xB9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xC9, 0xE5, 0xA4, 0xEF, 0x04, 0x7D, 0x7D, 0x15, 0x22, 
0x11, 0x95, 0x87, 0x07, 0x2B, 0xDB, 0xDB, 0xCD, 0x75, 0x82, 0xCD, 0x4D, 0x0F, 0xFB, 0xFB, 0x6E, 
0x26, 0x27, 0x15, 0x86, 0x86, 0x9E, 0x91, 0x65, 0x8D, 0xDE, 0xDE, 0x2A, 0x47, 0x47, 0xF2, 0x97, 
0x05, 0xC3, 0xD3, 0xDD, 0x9D, 0x95, 0xB1, 0xB1, 0x32, 0x1B, 0x1B, 0x1E, 0x3A, 0x3A, 0x6A, 0xA6, 
0xCA, 0xC1, 0x81, 0x8B, 0xE5, 0x65, 0x2F, 0x85, 0x82, 0x83, 0xF9, 0xF9, 0x22, 0xAA, 0x2A, 0x18, 
0x1C, 0x7C, 0xA1, 0xAB, 0xAB, 0xCA, 0xDA, 0x5A, 0x1B, 0x66, 0x88, 0x0B, 0x0B, 0x45, 0x62, 0xB1, 
0x27, 0x24, 0x49, 0x37, 0xD5, 0x97, 0x96, 0xDA, 0x49, 0x24, 0x1E, 0xF1, 0xFB, 0x3F, 0x42, 0x34, 
0xAC, 0xAD, 0xAE, 0x7A, 0xC9, 0x66, 0xEF, 0x19, 0x18, 0x78, 0xE1, 0xF5, 0x55, 0xB0, 0xBB, 0xEB, 
0x66, 0x66, 0xC6, 0x47, 0x7D, 0x0F, 0x8C, 0x84, 0x6D, 0x36, 0xDD, 0x7C, 0xFC, 0xA9, 0xAC, 0x56, 
0xDD, 0xFC, 0x6A, 0x4D, 0xFB, 0xC0, 0xFD, 0xEF, 0x22, 0xFD, 0x66, 0xA5, 0xFF, 0x7E, 0x4C, 0x7F, 
0x3D, 0xE7, 0x77, 0x1D, 0x9D, 0xB1, 0x7A, 0xAB, 0xAA, 0x55, 0x9D, 0x00, 0x00, 0x00, 0x00, 0x49, 
0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82  };

  String str = (char*)Favicon;
  //server.send(200, "image/png", str);
  server.send(200, "image/x-icon", str);
}
I tried with x-icon and png but again it did not work.

Kind regards

Ian

Galeforce9
Posts: 7
Joined: Thu Sep 10, 2020 8:22 pm

Re: Favicon

Postby Galeforce9 » Sun Mar 27, 2022 11:39 am

Hello,

Re-reading ths and more research seems I cannot use server.send as this is only for string use and as stated I need binary.

The Async library which I dont use has the server.send_P funtion which doesnt seem present in the webser.h library.

I beleive there is a server.streamFile(file, contentType), command but this only works with a file and file system but I need this to work with an array. I am still unable to find a solution if anyone has any ideas.

Thank you

Ian

boarchuz
Posts: 605
Joined: Tue Aug 21, 2018 5:28 am

Re: Favicon

Postby boarchuz » Sun Mar 27, 2022 11:54 am

Galeforce9 wrote:
Sun Mar 27, 2022 11:39 am
the server.send_P funtion which doesnt seem present in the webser.h library
https://github.com/espressif/arduino-es ... ver.h#L124 ?

pipi61
Posts: 60
Joined: Fri Dec 23, 2016 10:58 pm

Re: Favicon

Postby pipi61 » Sun Mar 27, 2022 12:33 pm

  1. /*
  2.     pl: https://icons8.com/icon/set/windows/all
  3. https://www.favicon-generator.org/
  4.  
  5. */
  6. const char PAGE_favicon[] PROGMEM = {   //faviconalarm.ico
  7.  
  8. 0x00,0x00,0x01,0x00, 0x01,0x00,0x10,0x10, 0x00,0x00,0x01,0x00, 0x20,0x00,0x68,0x04,
  9. 0x00,0x00,0x16,0x00, 0x00,0x00,0x28,0x00, 0x00,0x00,0x10,0x00, 0x00,0x00,0x20,0x00,
  10. 0x00,0x00,0x01,0x00, 0x20,0x00,0x00,0x00, 0x00,0x00,0x00,0x04, 0x00,0x00,0xEB,0x10,
  11. 0x00,0x00,0xEB,0x10, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0xFF,0xFF,
  12. 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,
  13. 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF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0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,
  73. 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,
  74. 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,
  75. 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x00,0x00,
  76. 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
  77. 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
  78. 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
  79. 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,
  80. };
............
  1. #include "c_Page_favicon.h"
.............
  1.  server.on("/favicon.ico", []()
  2.   {
  3.     Serial.println("favicon.ico");
  4.     //server.send_P(200, "image/x-icon", PAGE_favicon, sizeof(PAGE_favicon));
  5.     server.send_P(200, "image/x-icon", PAGE_favicon, sizeof(PAGE_favicon));
  6.     //      server.send(200, "text/html", "");
  7.   }    );
  8.  

Galeforce9
Posts: 7
Joined: Thu Sep 10, 2020 8:22 pm

Re: Favicon

Postby Galeforce9 » Sun Mar 27, 2022 1:03 pm

Hello,

Thank you all. I did get this working and on return found Pipi61 answer. I have since used the code provided to test.

So if i goto /favicon.ico I get the favicon displayed and in Edge I also get the favicon displayed in the title bar as it should, however in Chrome the favicon does not display in the title bar, but will display on screen with \favicon.ico.

I guess this is now a browser issue, I tried with Pipi61's icon and myown but neither display in Chrome.

Does anyone know the cause or a fix for this.

Thank you

Kind regards

Ian

pipi61
Posts: 60
Joined: Fri Dec 23, 2016 10:58 pm

Re: Favicon

Postby pipi61 » Sun Mar 27, 2022 2:07 pm

in my chrome ok.
Try clear cache in chrome

Galeforce9
Posts: 7
Joined: Thu Sep 10, 2020 8:22 pm

Re: Favicon

Postby Galeforce9 » Sun Mar 27, 2022 7:44 pm

Thanks to all who helped. Everything is now working correctly.

Kind regards

Ian

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Favicon

Postby lbernstone » Sun Mar 27, 2022 11:38 pm

Just as a follow up, you can use the command line utility xxd to easily convert a file to the c code equivalent. Change the output to a const char so that it stays mapped directly from your firmware instead of active memory.

Code: Select all

lbernstone@IdeaPad:~/Arduino/libraries/ESPAsyncWebServer/examples/ESP_AsyncFSBrowser/data$ xxd -i favicon.ico 
unsigned char favicon_ico[] = {
  0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x00,
  0x20, 0x00, 0x68, 0x04, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x28, 0x00,
  0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00,
...
  0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xf8, 0x0f,
  0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00
};
unsigned int favicon_ico_len = 1150;

Who is online

Users browsing this forum: Baidu [Spider] and 65 guests