Closed za3k closed 10 months ago
https://stackoverflow.com/questions/73656471/use-filetoblob-in-imagemagick well i'm a bit stuck using FileToBlob() if you can offer any help.
https://stackoverflow.com/questions/73656471/use-filetoblob-in-imagemagick well i'm a bit stuck using FileToBlob() if you can offer any help.
Maybe should be something like this:
void *blob = FileToBlob(filename, MagickMaxBufferExtent, &blob_length, &blob_exception);
or maybe:
void *blob = FileToBlob(filename, MAGICK_SSIZE_MAX, &blob_length, &blob_exception);
The second argument (extent) is not causing the issues. I started it as INT_MAX, sure, just left that out for clarity.
Proposed an ImageMagick feature to help us out. If someone has thoughts on a better way to do it, feel free to comment. https://github.com/ImageMagick/ImageMagick/issues/5554
Also, went ahead and reported my issues as a bug at https://github.com/ImageMagick/ImageMagick/issues/5553. I can get it to work for an 80K file but not a 100K file (note size is like 100MB), which makes me think MAYBE it's not just a me issue.
In the meantime, I've made sure this doesn't break stdin, and I think it could be merged. It just won't work for PDFs on stdin yet.
Confirmed the issue I was running into was a bug. ImageMagick has a patch, thanks ImageMagick!
I'll offer a PR that makes PDFs work on stdin too, once imagemagick's stable release includes their fix.
OK, ready for submission. Apparently I was wildly wrong about how setting the density works, and I can just do it unconditionally. This is now a one-line change.
Ping on this? It's a one-line change now so it seems pretty safe. You could change the default resolution to 300 or 600 if you prefer.
Merged, thanks!
PDF does not inherently encode a resolution--it's essentially a vector format. By default, ImageMagick samples it at a tiny 72dpi resolution, so many QR codes are not read.
Default .pdf to 300dpi sample rate to fix the issue.