belaviyo / save-images

Save loaded images in nested iframe pages
https://webextension.org/listing/save-images.html
250 stars 61 forks source link

Bug: "File Mask" don't work as expected #97

Open Thomas-SW opened 2 months ago

Thomas-SW commented 2 months ago

Bug: "File Mask" don't work as expected

Example: The pictures in an site are all recognised as JPG but they are all coded as WEBP So I will use the "File Mask" feature with the expression "[name].webp" But in the resulting ZIP all files named [name]-webp (with an "-" instead of ".") Tried some other special signs, all resultet in "-"

belaviyo commented 2 months ago

The file masking is used to rename filenames not extensions. Can you provide an example page with this JPG extension issue?

Thomas-SW commented 2 months ago

https://issuudownload.com/boschebikesystems/docs/boschae_hb2020_uk .jpg (but webp coded) images saved as .jpg

belaviyo commented 2 months ago

Do you mean all JPEG images are actually WebP with wrong file extensions?

For instance https://issuudownload.com/boschebikesystems/docs/boschae_hb2020_uk#lg=1&slide=5

I see https://image.isu.pub/200508114845-2a600b0beb5f2388992d42d368dbca81/jpg/page_6.jpg

The content type is 'image/jpeg'. Also the file includes JPEG magic code

Screenshot 2024-06-03 at 08 22 19
JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1059x1497, components 3
Thomas-SW commented 2 months ago

Hmmm...

All picture are saved as JPG, the way I do it doesn't matter. But opened in XnViewMP the file properties shows the format WEBP. If you save the picture in Firefox (right click - save as) FF will automaticly prompt "save as *.webp", not JPG. Adobe Acrobat can't import WEBP (that was the first time i recognise this problem) and I have to convert all files in JPG / PNG first...

webp

(and it is webp in HEX-code)

belaviyo commented 2 months ago

I see, I tested on Chrome and images are in fact JPEG. I can reproduce the issue on Firefox.

Thomas-SW commented 2 months ago

crazy behavior...

belaviyo commented 2 months ago

This extension uses the filename that the server returns when it can. So, for now, you can load the extension (the v2 directory) as a temporary add-on and change the code to force-rename as WebP.

https://github.com/belaviyo/save-images/blob/master/v2/data/ui/guess.js#L106

 .slice(0, 60)).join(extension);

to

.slice(0, 60)).join('.webp');

Alternatively use the extension on Chrome.

Thomas-SW commented 2 months ago

OK and many thanks!

For your information: I now tried a direct download with wget and the "JPG"-links to the files on the server (no Firefox used). The files are originally coded in webp.

belaviyo commented 2 months ago

Seems like the server returns WebP or JPG based on your IP address. It is not browser dependent.