Skip to content
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

Is it possible to return a blob via stdout #1547

Closed
toomanylogins opened this issue Apr 25, 2023 · 3 comments
Closed

Is it possible to return a blob via stdout #1547

toomanylogins opened this issue Apr 25, 2023 · 3 comments

Comments

@toomanylogins
Copy link

toomanylogins commented Apr 25, 2023

Rather than write an output file to temp can a processed image be returned via stdout ?

I am running latest 0.22 on a folder as follows.

sic --glob-input "G:/Temp/*.{jpg, jpeg, png}" --glob-output "C:/Users/Paul/AppData/Local/Temp/youdocms" --resize 200 200

after about 70 files I get format error but no file ref. The directory does inc files other than jpg,jpeg and png.

Thanks
Paul

@foresterre
Copy link
Owner

foresterre commented Apr 25, 2023

Rather than write an output file to temp can a processed image be returned via stdout ?

For individual files, you can do the following to get a blob:

sic --output-format png --input .\resources\logo\sic_500.jpg --resize 200 200 >> out.png

Files which use --glob-input currently always require --glob-output to be present, and this mode doesn't currently support stdout.

Looking at your paths, I think you're on Windows; as a workaround you could use the following Powershell:

Get-ChildItem -Recurse ".\resources" -Include "*.jpg","*.jpeg","*.png" | ForEach-Object { sic --input $_.FullName --output somedir/$($_.Name) --resize 200 200 }

For your directories:

Get-ChildItem -Recurse "G:/Temp" -Include "*.jpg","*.jpeg","*.png" | ForEach-Object { sic --input $_.FullName --output C:/Users/Paul/AppData/Local/Temp/youdocms/$($_.Name) --resize 200 200 }

after about 70 files I get format error but no file ref. The directory does inc files other than jpg,jpeg and png.

That's not good! I should improve the error message and/or add a flag to allow for (silent/with a warning to stderr) failures.

If you still have the exact error that would be helpful :).

Rather than write an output file to temp can a processed image be returned via stdout ?

Say that I would implement this, in what way would you expect the different images to be output? i.e. if you have a stream of byte buffers, how do you:

A) know the type of the output file* (e.g. png, jpg, bmp), and
B) know where one image ends, and the next begins (e.g. a next line in jsonlines).

* some are guessable by their file header

@toomanylogins
Copy link
Author

toomanylogins commented Apr 27, 2023

Thank you for reply. I have this working via blob or file and looping through the files. Not getting the format error. I will try to track down the file that is causing the problem if I try to process a directory.

However if using individual files with blob output the blob is only created if the output format matches the input.

sic.exe --output-format jpg --input "G:\Temp\test\IMG_6344.PNG" --resize 200 200 >> empty blob

The error is as follows.

Error: Unable to save image.

Caused by:
0: The decoder for Jpeg does not support the color type Rgba16
1: The decoder for Jpeg does not support the color type Rgba16

if the output format is png with same file the blob is returned.

@foresterre
Copy link
Owner

foresterre commented Apr 27, 2023

after about 70 files I get format error but no file ref. The directory does inc files other than jpg,jpeg and png.

That's not good! I should improve the error message and/or add a flag to allow for (silent/with a warning to stderr) failures.

I added error context in #1555.
Released as 0.22.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants