Redirect output to standard out instead of file
Clash Royale CLAN TAG#URR8PPP
I am writing a java wrapper for convert
(which is part of image magick). What I want to do is call a command like convert -thumbnail 1024 test.JPG >(cat)
to make it print the thumbnails byte stream to standard out. Afterwards I want to read from this stream and store it in a blob store.
I'm having difficulties with the command above as it looks like it can't handle binary data. After printing the bytes it also prints something like 62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c
.
I would like to avoid writing to a temporary file because I don't want to deal with any directory permissions.
What am I doing wrong in my command? Is it cat
that can't handle the binary data or is it something else?
bash io-redirection imagemagick
add a comment |
I am writing a java wrapper for convert
(which is part of image magick). What I want to do is call a command like convert -thumbnail 1024 test.JPG >(cat)
to make it print the thumbnails byte stream to standard out. Afterwards I want to read from this stream and store it in a blob store.
I'm having difficulties with the command above as it looks like it can't handle binary data. After printing the bytes it also prints something like 62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c
.
I would like to avoid writing to a temporary file because I don't want to deal with any directory permissions.
What am I doing wrong in my command? Is it cat
that can't handle the binary data or is it something else?
bash io-redirection imagemagick
1
You may need to use a binary-to-text encoding scheme like Base64 for this to work.
– Haxiel
Dec 27 '18 at 13:35
@Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
– Selim
Dec 27 '18 at 14:42
add a comment |
I am writing a java wrapper for convert
(which is part of image magick). What I want to do is call a command like convert -thumbnail 1024 test.JPG >(cat)
to make it print the thumbnails byte stream to standard out. Afterwards I want to read from this stream and store it in a blob store.
I'm having difficulties with the command above as it looks like it can't handle binary data. After printing the bytes it also prints something like 62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c
.
I would like to avoid writing to a temporary file because I don't want to deal with any directory permissions.
What am I doing wrong in my command? Is it cat
that can't handle the binary data or is it something else?
bash io-redirection imagemagick
I am writing a java wrapper for convert
(which is part of image magick). What I want to do is call a command like convert -thumbnail 1024 test.JPG >(cat)
to make it print the thumbnails byte stream to standard out. Afterwards I want to read from this stream and store it in a blob store.
I'm having difficulties with the command above as it looks like it can't handle binary data. After printing the bytes it also prints something like 62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c
.
I would like to avoid writing to a temporary file because I don't want to deal with any directory permissions.
What am I doing wrong in my command? Is it cat
that can't handle the binary data or is it something else?
bash io-redirection imagemagick
bash io-redirection imagemagick
asked Dec 27 '18 at 13:16
SelimSelim
1033
1033
1
You may need to use a binary-to-text encoding scheme like Base64 for this to work.
– Haxiel
Dec 27 '18 at 13:35
@Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
– Selim
Dec 27 '18 at 14:42
add a comment |
1
You may need to use a binary-to-text encoding scheme like Base64 for this to work.
– Haxiel
Dec 27 '18 at 13:35
@Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
– Selim
Dec 27 '18 at 14:42
1
1
You may need to use a binary-to-text encoding scheme like Base64 for this to work.
– Haxiel
Dec 27 '18 at 13:35
You may need to use a binary-to-text encoding scheme like Base64 for this to work.
– Haxiel
Dec 27 '18 at 13:35
@Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
– Selim
Dec 27 '18 at 14:42
@Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
– Selim
Dec 27 '18 at 14:42
add a comment |
2 Answers
2
active
oldest
votes
From the Output Filename section of the command-line processing web page:
Standard Out
Unix permits the output of one command to be piped to another. ImageMagick permits piping one command to another with a filename of -.
In this example we pipe the output of convert to the display program:
magick logo: gif:- | display gif:-
Your command-line could then start with:
convert -thumbnail 1024 test.JPG -
... or optionally converted to other formats with the proper prefix:
convert -thumbnail 1024 test.JPG png:-
... at which point you could then pipe that output to your blob-store-reader:
convert -thumbnail 1024 test.JPG - | blob-store-reader
This did the trick, thanks! I should've read the docs more thoroughly..
– Selim
Dec 27 '18 at 14:43
add a comment |
cat
is made for lines and text, but it doesn't care if it's handling binary data except for a few control characters. It's the terminal (your normal stdout) that can't cope with binary data and presumably gets stuck.
BTW, using "process substitution" for the required output file is like taking the scenic route. And, you should use it correctly, adding another >
for the redirection. But, why at all? man convert
:
Specify 'file' as '-' for standard input or output.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491124%2fredirect-output-to-standard-out-instead-of-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
From the Output Filename section of the command-line processing web page:
Standard Out
Unix permits the output of one command to be piped to another. ImageMagick permits piping one command to another with a filename of -.
In this example we pipe the output of convert to the display program:
magick logo: gif:- | display gif:-
Your command-line could then start with:
convert -thumbnail 1024 test.JPG -
... or optionally converted to other formats with the proper prefix:
convert -thumbnail 1024 test.JPG png:-
... at which point you could then pipe that output to your blob-store-reader:
convert -thumbnail 1024 test.JPG - | blob-store-reader
This did the trick, thanks! I should've read the docs more thoroughly..
– Selim
Dec 27 '18 at 14:43
add a comment |
From the Output Filename section of the command-line processing web page:
Standard Out
Unix permits the output of one command to be piped to another. ImageMagick permits piping one command to another with a filename of -.
In this example we pipe the output of convert to the display program:
magick logo: gif:- | display gif:-
Your command-line could then start with:
convert -thumbnail 1024 test.JPG -
... or optionally converted to other formats with the proper prefix:
convert -thumbnail 1024 test.JPG png:-
... at which point you could then pipe that output to your blob-store-reader:
convert -thumbnail 1024 test.JPG - | blob-store-reader
This did the trick, thanks! I should've read the docs more thoroughly..
– Selim
Dec 27 '18 at 14:43
add a comment |
From the Output Filename section of the command-line processing web page:
Standard Out
Unix permits the output of one command to be piped to another. ImageMagick permits piping one command to another with a filename of -.
In this example we pipe the output of convert to the display program:
magick logo: gif:- | display gif:-
Your command-line could then start with:
convert -thumbnail 1024 test.JPG -
... or optionally converted to other formats with the proper prefix:
convert -thumbnail 1024 test.JPG png:-
... at which point you could then pipe that output to your blob-store-reader:
convert -thumbnail 1024 test.JPG - | blob-store-reader
From the Output Filename section of the command-line processing web page:
Standard Out
Unix permits the output of one command to be piped to another. ImageMagick permits piping one command to another with a filename of -.
In this example we pipe the output of convert to the display program:
magick logo: gif:- | display gif:-
Your command-line could then start with:
convert -thumbnail 1024 test.JPG -
... or optionally converted to other formats with the proper prefix:
convert -thumbnail 1024 test.JPG png:-
... at which point you could then pipe that output to your blob-store-reader:
convert -thumbnail 1024 test.JPG - | blob-store-reader
answered Dec 27 '18 at 14:12
Jeff SchallerJeff Schaller
39k1054125
39k1054125
This did the trick, thanks! I should've read the docs more thoroughly..
– Selim
Dec 27 '18 at 14:43
add a comment |
This did the trick, thanks! I should've read the docs more thoroughly..
– Selim
Dec 27 '18 at 14:43
This did the trick, thanks! I should've read the docs more thoroughly..
– Selim
Dec 27 '18 at 14:43
This did the trick, thanks! I should've read the docs more thoroughly..
– Selim
Dec 27 '18 at 14:43
add a comment |
cat
is made for lines and text, but it doesn't care if it's handling binary data except for a few control characters. It's the terminal (your normal stdout) that can't cope with binary data and presumably gets stuck.
BTW, using "process substitution" for the required output file is like taking the scenic route. And, you should use it correctly, adding another >
for the redirection. But, why at all? man convert
:
Specify 'file' as '-' for standard input or output.
add a comment |
cat
is made for lines and text, but it doesn't care if it's handling binary data except for a few control characters. It's the terminal (your normal stdout) that can't cope with binary data and presumably gets stuck.
BTW, using "process substitution" for the required output file is like taking the scenic route. And, you should use it correctly, adding another >
for the redirection. But, why at all? man convert
:
Specify 'file' as '-' for standard input or output.
add a comment |
cat
is made for lines and text, but it doesn't care if it's handling binary data except for a few control characters. It's the terminal (your normal stdout) that can't cope with binary data and presumably gets stuck.
BTW, using "process substitution" for the required output file is like taking the scenic route. And, you should use it correctly, adding another >
for the redirection. But, why at all? man convert
:
Specify 'file' as '-' for standard input or output.
cat
is made for lines and text, but it doesn't care if it's handling binary data except for a few control characters. It's the terminal (your normal stdout) that can't cope with binary data and presumably gets stuck.
BTW, using "process substitution" for the required output file is like taking the scenic route. And, you should use it correctly, adding another >
for the redirection. But, why at all? man convert
:
Specify 'file' as '-' for standard input or output.
answered Dec 27 '18 at 14:18
RudiCRudiC
4,2191312
4,2191312
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491124%2fredirect-output-to-standard-out-instead-of-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You may need to use a binary-to-text encoding scheme like Base64 for this to work.
– Haxiel
Dec 27 '18 at 13:35
@Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
– Selim
Dec 27 '18 at 14:42