-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write to standard out #56
Comments
Not currently, but a pull request would be very welcome. I think most ImageMagick commands support writing to standard out. |
I started looking at this as I kinda have a need for it as well. It looks fairly straight forward, but I'm struggling with what the API should look like (I think I've actually spent more time thinking about the API than it would to actually do the work based on what I'm looking at for the imagemagick docs 😓 ) For my usage I've got an inline base64 encoded image that I'd like to resize and get an inline output back. The best idea I've come up with is to effectively pass the base64 encoded image to open, and populate the path. For the output, I'd do the same, if save is passed with an |
The work I was doing that would involve this has been put on the back burner so I never looked much further into it. I'd love to see this implemented though and I'd be happy to help. |
I spent an hour with this the other evening and its functionally working. Unfortunately;
Part of the pain is that a bunch of functions all assume the input and output are file system based and take actions based on extensions, the path, etc. which for my use case is a pain. For just output these mostly dont really matter and it's a special case in the save function, basically (output path of I'd like to come up with something a more elegant/cleaner, that allows both input and output without touching the file system, hopefully without breaking the API (although I'm not entirely convinced thats going to be possible and API design is my weakest skill). I'm going away on my first proper holiday in several years next week (🎉 ), and I'm not sure how much time I'll be able to put into this until the end of June. If someone wants to pick up before then I won't get upset 😄 |
Hello @theangryangel -- I am interested about this issue, do you have a branch with the "hack"? |
@theangryangel I opened #62 |
Merged #62 which adds buffer support to Before release I'd like to:
|
@talklittle thanks for you hard work! @kpanic thank you! |
I'm looking into
Compared with regular operation:
Work so far is at branch https://github.com/talklittle/mogrify/tree/save-buffer but I consider this upstream bug a blocker. |
Same behaviour on $ mogrify -write - -resize 100x100 bender.jpg | wc -c
8552
$ mogrify -write tmp.jpg -resize 100x100 bender.jpg
$ wc -c tmp.jpg
4276 tmp.jpg
$ mogrify --version
Version: ImageMagick 6.9.10-14 Q16 x86_64 20181023 https://imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib |
@talklittle I've opened an issue on imagemagick. They are fixing it, but apparently you can pass |
@lucacorti Thanks for opening the ImageMagick issue. I tested the The documentation says (https://imagemagick.org/script/command-line-options.php#write):
It apparently tells ImageMagick to rewrite the input image file to disk. This is a problem because it apparently can change the bytes and width/height of the original image. Tested on ImageMagick 6.9.7. So unfortunately we can't use When the upstream fix becomes stable, we can merge the code to use buffers. We'll probably want to raise an error if trying to use the feature on older ImageMagick versions. |
Does this library have the ability to create an image and then write to standard out without having to interact with the file system?
The text was updated successfully, but these errors were encountered: