pimcore icon indicating copy to clipboard operation
pimcore copied to clipboard

skip crop on vector graphics thumbnails

Open jheimbach opened this issue 2 years ago • 5 comments

Changes in this pull request

SVG Image Thumbnails cannot be cropped if the Thumbnail config uses the original format.

Imagemagick tries to crop the svg and fails with:

ImagickException: delegate failed `'potrace' --svg --output '%o' '%i'' @ error/delegate.c/InvokeDelegate/1924 in /var/www/html/vendor/pimcore/pimcore/lib/Image/Adapter/Imagick.php:262

I fixed it with skipping the crop mechanism on vector graphics if the thumbnail configuration uses the original format.

Steps to reproduce

  • create thumbnail config with format = original
  • create image editable that uses the thumbnail
  • add svg image to editable and crop image to a different size

Additional info

  • not sure if we should document this and if yes where
  • maybe we have to exclude multiple formats?
  • i tried with isRasterizedSVG but this produces the same error when Format was original

jheimbach avatar Jan 12 '24 12:01 jheimbach

Review Checklist

  • [ ] Target branch (11.1 for bug fixes, others 11.x)
  • [ ] Tests (if it's testable code, there should be a test for it - get help)
  • [ ] Docs (every functionality needs to be documented, see here)
  • [ ] Migration incl. install.sql (e.g. if the database schema changes, ...)
  • [ ] Upgrade notes (deprecations, important information, migration hints, ...)
  • [ ] Label
  • [ ] Milestone

github-actions[bot] avatar Jan 12 '24 12:01 github-actions[bot]

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Jan 29 '24 10:01 sonarqubecloud[bot]

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Mar 13 '24 07:03 sonarqubecloud[bot]

@jheimbach thank you very much for your PR. Yes, we should add this info to the documentation, I think here would be a good place for it: https://pimcore.com/docs/platform/Pimcore/Documents/Editables/Image#field-specific-image-cropping-for-documents

Additionally I think we have the same issue when using ORIGINAL in combination with vector formats with normal thumbnail definitions, so not in the context of the image editable. In this case pretty much all available transformations are affected I'm afraid. So I think we should add this information here as well: https://pimcore.com/docs/platform/Pimcore/Assets/Working_with_Thumbnails/Image_Thumbnails/

And maybe try to just ignore those transformations then 🤔

brusch avatar Jul 12 '24 09:07 brusch

@jheimbach 🏓 any updates? 😊 Thanks in advance!

brusch avatar Aug 08 '24 09:08 brusch