Page 1 of 2
[SOLVED] pipe command output to convert ?
Posted: 2008-12-24T13:50:34-07:00
by deej
Is there, I am wondering, a way of piping the output of a command -
the 'fortune' command for example - to 'convert' in order to save the
output in png format ? I am currently piping to 'enscript' and then
passing the resultant image to 'convert'. I'd like to get rid of the
'enscript' step, if possible.
Here is an example of what I'm doing at the moment:
Code: Select all
fortune | enscript -o From_Enscript -B -r -fCourier@16/18
convert -trim From_Enscript result.png
Merry Xmas to all...
Deej
Re: pipe command output to convert ?
Posted: 2008-12-24T14:19:03-07:00
by el_supremo
This works with Windows XP and IM 6.4.6 Q8 so it should work with Linux.
Code: Select all
echo Merry Christmas | convert -font Arial -pointsize 72 -fill red -background green text:- -trim cap.png
The piped text is picked up by "text:-" and the rest sets up the font/size/colour and then trims the result.
Pete
Re: pipe command output to convert ?
Posted: 2008-12-24T14:41:07-07:00
by deej
Ah, many thanks el_supremo, I shall give it
a go - and report back.
The Seasons Best Wishes to you...
Deej
Re: pipe command output to convert ?
Posted: 2008-12-24T14:48:23-07:00
by el_supremo
The Seasons Best Wishes to you...
and to you too
@magick/Anthony
Although text:- reads the standard input, I can't get caption:- or label:- to do the same thing. Are they supposed to work or is this function limited to text:-?
Pete
Re: pipe command output to convert ?
Posted: 2008-12-24T17:22:06-07:00
by fmw42
el_supremo wrote:The Seasons Best Wishes to you...
and to you too
@magick/Anthony
Although text:- reads the standard input, I can't get caption:- or label:- to do the same thing. Are they supposed to work or is this function limited to text:-?
Pete
Pete,
These work for me (IM 6.4.8-1 Q16):
echo "Merry Christmas" | convert -font Arial -pointsize 72 -fill red -background green \
text:- -trim tmp1.png
But you need @- for label: and caption:
echo "Merry Christmas" | convert -font Arial -pointsize 72 -fill red -background green \
label:@- -trim tmp2.png
echo "Merry Christmas" | convert -font Arial -pointsize 72 -fill red -background green \
-size 320x caption:@- -trim tmp3.png
Seems a bit inconsistent. But there must be some reason. Also, text:@- does not work.
Fred
Re: pipe command output to convert ?
Posted: 2008-12-24T18:40:56-07:00
by el_supremo
On Windows those caption and label commands don't work. IM 6.4.6 Q8
label:@- causes this error:
Code: Select all
convert: unable to read blob `-': No such file or directory @ blob.c/FileToBlob/868.
imconvert: missing an image filename `cap.png' @ convert.c/ConvertImageCommand/2710.
whereas caption:@- causes this:
Code: Select all
convert: geometry does not contain image `@-' @ statistic.c/GetImageBoundingBox/217.
imconvert: unable to read blob `-': No such file or directory @ blob.c/FileToBlob/868.
I don't understand the complaint about geometry. I can make the -size much larger than it needs and it still complains
Pete
Re: pipe command output to convert ?
Posted: 2008-12-24T19:21:00-07:00
by fmw42
el_supremo wrote:On Windows those caption and label commands don't work. IM 6.4.6 Q8
label:@- causes this error:
Code: Select all
convert: unable to read blob `-': No such file or directory @ blob.c/FileToBlob/868.
imconvert: missing an image filename `cap.png' @ convert.c/ConvertImageCommand/2710.
whereas caption:@- causes this:
Code: Select all
convert: geometry does not contain image `@-' @ statistic.c/GetImageBoundingBox/217.
imconvert: unable to read blob `-': No such file or directory @ blob.c/FileToBlob/868.
I don't understand the complaint about geometry. I can make the -size much larger than it needs and it still complains
Pete
Guess we need to hear from Magick or Anthony. Those work for me on Mac OSX Tiger (unix). So must be some special issue with @ on windows. Did you try escaping it, I assume ^@-
Fred
Re: pipe command output to convert ?
Posted: 2008-12-24T19:49:19-07:00
by el_supremo
I tried all sorts of escapes and quoting and nothing works.
Pete.
Merry Christmas Fred and All
Re: pipe command output to convert ?
Posted: 2008-12-24T21:51:53-07:00
by fmw42
el_supremo wrote:I tried all sorts of escapes and quoting and nothing works.
Pete.
Merry Christmas Fred and All
Happy Holidays to you too, Pete.
Re: pipe command output to convert ?
Posted: 2008-12-25T01:40:59-07:00
by anthony
The '-' is a special filename meaning either read from standard input (piped input ot keyboard) or write to standard output (pipe to another command or to the screen).
text: reads from a file name so you use
text:-
label: and
caption: read a string. so you prepend '@' to have the string read from a filename EG:
label:@-
el_supremo wrote:whereas caption:@- causes this:
Code: Select all
convert: geometry does not contain image `@-' @ statistic.c/GetImageBoundingBox/217.
imconvert: unable to read blob `-': No such file or directory @ blob.c/FileToBlob/868.
I don't understand the complaint about geometry. I can make the -size much larger than it needs and it still complains
If you read IM Examples on
text to image handling caption, the first thing is says is that
caption: requires a
-size setting to specify a image 'width' for the caption for word wrapping purposes. If you don't have it you get a geometry error as you saw.
Re: pipe command output to convert ?
Posted: 2008-12-25T03:19:00-07:00
by deej
Thank you to everyone who replied, this is what finally worked for me [ on Linux ]:
Code: Select all
convert -font courier -pointsize 18 label:@- -trim signature1.png
( thx fmw32
)
Deej
Re: [SOLVED] pipe command output to convert ?
Posted: 2008-12-25T03:29:17-07:00
by anthony
After the
-trim add a
+repage before saving the image, so as to avoid problems with 'virtual canvas offsets' that is left for expert users.
See IM Usage Examples, Trim
http://www.imagemagick.org/Usage/crop/#trim
Re: [SOLVED] pipe command output to convert ?
Posted: 2008-12-25T05:35:41-07:00
by deej
After the -trim add a +repage before saving the image, so as to avoid problems with 'virtual canvas offsets' that is left for expert users.
OK, done. All working fine now, thanks again everyone
Deej
Re: [SOLVED] pipe command output to convert ?
Posted: 2008-12-26T14:20:52-07:00
by el_supremo
the first thing is says is that caption: requires a -size setting
Yes I know, that's why I said "I can make the -size much larger than it needs and it still complains "
These all fail no matter how I escape them:
Code: Select all
>echo Merry Christmas | imconvert -font Arial -pointsize 72 -fill red -background green label:@- -trim cap_l.png
imconvert: unable to read blob `-': No such file or directory @ blob.c/FileToBlob/868.
imconvert: missing an image filename `cap_l.png' @ convert.c/ConvertImageCommand/2710
>echo Merry Christmas | imconvert -font Arial -pointsize 72 -fill red -background green label:^@- -trim cap_l.png
imconvert: unable to read blob `-': No such file or directory @ blob.c/FileToBlob/868.
imconvert: missing an image filename `cap_l.png' @ convert.c/ConvertImageCommand/2710.
>echo Merry Christmas | imconvert -font Arial -pointsize 72 -fill red -background green "label:@-" -trim cap_l.png
imconvert: unable to read blob `-': No such file or directory @ blob.c/FileToBlob/868.
imconvert: missing an image filename `cap_l.png' @ convert.c/ConvertImageCommand/2710.
>echo Merry Christmas | imconvert -font Arial -pointsize 72 -fill red -background green -size 1000x500 caption:@- -trim c
ap_c.png
imconvert: geometry does not contain image `@-' @ statistic.c/GetImageBoundingBox/217.
imconvert: unable to read blob `-': No such file or directory @ blob.c/FileToBlob/868.
This is with ImageMagick 6.4.6 2008-12-01 Q8
Pete
Re: [SOLVED] pipe command output to convert ?
Posted: 2008-12-30T00:41:35-07:00
by anthony
el_supremo wrote:the first thing is says is that caption: requires a -size setting
Yes I know, that's why I said "I can make the -size much larger than it needs and it still complains "[/code]
Works for me under linux. Could pipelines be a problem under windows?
I have had no indication that '@' needs any form of escaping under windows. But no reports of success for it either. Of course I am not a windows user so can only go by what I have been told.
And what I have been told has been noted in IM examples,
http://www.imagemagick.org/Usage/api/#windows