nodeca / probe-image-size

Get image size without full download. Supported image types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, PSD, ICO.
MIT License
978 stars 77 forks source link

Get data from Images in asset manager #75

Closed janwillemwilmsen closed 2 years ago

janwillemwilmsen commented 2 years ago

Hi, Is it possible to get the probe-image-size results from image urls like this: https://www.debijenkorf.nl/content/dam/images_debijenkorf/webshop/campagnes/creatieve-campagnes/2022/zomer/hero/flight-2/home/1.1_home_topbanner__hero_celebratelove_flight2_5120x1700.jpg.gravity/780x312-49.3880489560835x42.3160173160173

Because of the parameters after the .jpg a different size and focus is dynamically generated from the base image (https://www.debijenkorf.nl/content/dam/images_debijenkorf/webshop/campagnes/creatieve-campagnes/2022/zomer/hero/flight-2/home/1.1_home_topbanner__hero_celebratelove_flight2_5120x1700.jpg).

I get an error when probing the url with parameters after the filetype. Wondering if should create an exception in my application, or if this use case might be something to add in probe-image-size.

puzrin commented 2 years ago

CLI:

./support/dump.js https://www.debijenkorf.nl/content/dam/images_debijenkorf/webshop/campagnes/creatieve-campagnes/2022/zomer/hero/flight-2/home/1.1_home_topbanner__hero_celebratelove_flight2_5120x1700.jpg.gravity/780x312-49.3880489560835x42.3160173160173

As far as i see, server returns 403 status (fobidden). That means it does not like request. Usually, that means extra restrictions, based on

If you wish to investigate, i'd suggest to inspect firefox headers, and create the same list for prober request. Then repeat requests and drop headers one-by-one until find what is critical for that server.

With high probability problem is with user agent.

janwillemwilmsen commented 2 years ago

Thanks for your answer Puzrin! Good to know 'probe-image-size' would normally recognize file extensions with additional values(.jpg.gravity/7...).

Took the headers of an image which got a good result in the probe (https://www.debijenkorf.nl/content/dam/images_debijenkorf/webshop/system/Thuiswinkel_Waarborg.png) and added those to the probe script, dropped headers and changed many of them. But no luck so far. Think Cloudflare is detecting Playwright. Strange thing is that only images with parameters give an error, and the images without extra values after the filetype end up giving a good result.

One question about the cli : could you describe how to run it? I am on Windows.

No luck. Hope you can share some pointers.

puzrin commented 2 years ago

Clone the repo, then run npm i to install dependencies, then run dumper script with desired params. That's a standard way for all nodejs projects.

janwillemwilmsen commented 2 years ago

Oke thanks!

Played around with the CLI, tested other images with and without parameters. Found that adding a file extension after the parameters the probe did succeed.

image in html: https://www.debijenkorf.nl/content/dam/images_debijenkorf/webshop/campagnes/creatieve-campagnes/2022/zomer/hero/flight-2/home/1.1_home_topbanner__hero_celebratelove_flight2_5120x1700.jpg.gravity/780x312-49.3880489560835x42.3160173160173 --> no probe data

image with added extension: https://www.debijenkorf.nl/content/dam/images_debijenkorf/webshop/campagnes/creatieve-campagnes/2022/zomer/hero/flight-2/home/1.1_home_topbanner__hero_celebratelove_flight2_5120x1700.jpg.gravity/780x312-49.3880489560835x42.3160173160173.jpg --> does have probe data.