Command Produces Two FIles [ SOLVED ]

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
lindylex
Posts: 23
Joined: 2014-02-27T16:36:22-07:00
Authentication code: 6789

Command Produces Two FIles [ SOLVED ]

Post by lindylex »

This command produces two files r2.png and -composite. What do I need to modify so it does not produce the "-composite"?

Code: Select all

convert bgPapaer.jpg \( -size 950x950 -background "rgba(0,0,0,0)" -font /home/lex/share/Mo_De_Studio/audio_blog/OpenSans/OpenSans-ExtraBold.ttf -fill "#000000" caption:"$(cat ./temp.txt)" \( +clone -shadow 0x0+0+0 \) +swap -background "rgba(0,0,0,0)" -layers merge +repage \) -gravity center -composite -gravity northwest -pointsize 50 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +30+0 "1/232"> -composite -gravity south -pointsize 40 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +0+10 "Robert Greene, Joost Elffers" convert bgPapaer.jpg \( -size 950x950 -background "rgba(0,0,0,0)" -font /home/lex/share/Mo_De_Studio/audio_blog/OpenSans/OpenSans-ExtraBold.ttf -fill "#000000" caption:"$(cat ./temp.txt)" \( +clone -shadow 0x0+0+0 \) +swap -background "rgba(0,0,0,0)" -layers merge +repage \) -gravity center -composite -gravity northwest -pointsize 50 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +30+0 "1/232"> -composite -gravity south -pointsize 40 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +0+10 "Robert Greene, Joost Elffers" r2.png

Thanks
Last edited by lindylex on 2019-01-03T19:45:38-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Command Produces Two FIles

Post by snibgo »

What you have shown isn't a valid IM command, unless you have an image file named "convert" (which would be a really bad idea).

I suspect you have somehow combined two commands into one.

I suggest you break your command into logical lines, to help anyone understand it.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Command Produces Two FIles

Post by fmw42 »

One suggestion is to reformat to put each parenthesis step on a separate line and put \ at the end of each line. That way, we might be able to understand better what you are doing.

Another help would be to put a numbered comment line above your whole command for each line of the reformatted command. That way we can understand better what each parenthesis section is supposed to be doing.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Command Produces Two FIles

Post by magick »

It looks like your command is improperly copy/pasted. Tossing the first part of your command, we get a valid ImageMagick script:

Code: Select all

convert bgPapaer.jpg \( -size 950x950 -background "rgba(0,0,0,0)" -font /home/lex/share/Mo_De_Studio/audio_blog/OpenSans/OpenSans-ExtraBold.ttf -fill "#000000" caption:"$(cat ./temp.txt)" \( +clone -shadow 0x0+0+0 \) +swap -background "rgba(0,0,0,0)" -layers merge +repage \) -gravity center -composite -gravity northwest -pointsize 50 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +30+0 "1/232"> -composite -gravity south -pointsize 40 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +0+10 "Robert Greene, Joost Elffers" r2.png
Does that work for you?
lindylex
Posts: 23
Joined: 2014-02-27T16:36:22-07:00
Authentication code: 6789

Re: Command Produces Two FIles

Post by lindylex »

magick wrote: 2019-01-02T18:01:38-07:00 It looks like your command is improperly copy/pasted. Tossing the first part of your command, we get a valid ImageMagick script:

Code: Select all

convert bgPapaer.jpg \( -size 950x950 -background "rgba(0,0,0,0)" -font /home/lex/share/Mo_De_Studio/audio_blog/OpenSans/OpenSans-ExtraBold.ttf -fill "#000000" caption:"$(cat ./temp.txt)" \( +clone -shadow 0x0+0+0 \) +swap -background "rgba(0,0,0,0)" -layers merge +repage \) -gravity center -composite -gravity northwest -pointsize 50 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +30+0 "1/232"> -composite -gravity south -pointsize 40 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +0+10 "Robert Greene, Joost Elffers" r2.png
Does that work for you?
Thanks it worked.

Code: Select all

convert bgPapaer.jpg \( -size 950x950 -background "rgba(0,0,0,0)" -font /home/lex/share/Mo_De_Studio/audio_blog/OpenSans/OpenSans-ExtraBold.ttf -fill "#000000" caption:"$(cat ./temp.txt)" \( +clone -shadow 0x0+0+0 \) +swap -background "rgba(0,0,0,0)" -layers merge +repage \) -gravity center -composite -gravity northwest -pointsize 50 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +30+0 "1/232"> -composite -gravity south -pointsize 40 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +0+10 "Robert Greene, Joost Elffers" r2.png

I read this documentation

Code: Select all

http://www.imagemagick.org/Usage/basics/#parenthesis
It does not clearly explain how to use parenthesis for multiple command. Can you please explain some more or guide me to something more informative?
lindylex
Posts: 23
Joined: 2014-02-27T16:36:22-07:00
Authentication code: 6789

Re: Command Produces Two FIles

Post by lindylex »

UPDATE I spoke to soon.

This command my original command, generates two files "r2.png" and "-composite".

Code: Select all

 convert bgPapaer.jpg \( -size 950x950 -background "rgba(0,0,0,0)" -font /home/lex/share/Mo_De_Studio/audio_blog/OpenSans/OpenSans-ExtraBold.ttf -fill "#000000" caption:"$(cat ./temp.txt)" \( +clone -shadow 0x0+0+0 \) +swap -background "rgba(0,0,0,0)" -layers merge +repage \) -gravity center -composite -gravity northwest -pointsize 50 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +30+0 "1/232"> -composite -gravity south -pointsize 40 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +0+10 "Robert Greene, Joost Elffers" r2.png 
lindylex
Posts: 23
Joined: 2014-02-27T16:36:22-07:00
Authentication code: 6789

Re: Command Produces Two FIles

Post by lindylex »

Yes that was a mistake with the original post.
snibgo wrote: 2019-01-02T15:31:35-07:00 What you have shown isn't a valid IM command, unless you have an image file named "convert" (which would be a really bad idea).

I suspect you have somehow combined two commands into one.

I suggest you break your command into logical lines, to help anyone understand it.
lindylex
Posts: 23
Joined: 2014-02-27T16:36:22-07:00
Authentication code: 6789

Re: Command Produces Two FIles

Post by lindylex »

Here it is broken out.

Code: Select all

convert bgPapaer.jpg \   << This is the background image

Code: Select all

( -size 950x950 -background "rgba(0,0,0,0)" -font /home/lex/share/Mo_De_Studio/audio_blog/OpenSans/OpenSans-ExtraBold.ttf -fill "#000000" caption:"$(cat ./temp.txt)"  << This creates an image with a trasparent bg and uses the words from the text file temp.txt as the caption.

Code: Select all

\( +clone -shadow 0x0+0+0 \) +swap -background "rgba(0,0,0,0)" -layers merge +repage \)  << This layers the two images.

Code: Select all

-gravity center -composite -gravity northwest -pointsize 50 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +30+0 "1/232">   << This creates a text caption and places it on the top left side of the image.

Code: Select all

-composite -gravity south -pointsize 40 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +0+10 "Robert Greene, Joost Elffers" << This creates a text caption and places it at the bottom of the image

Code: Select all

r2.png  << This is the final file name.
fmw42 wrote: 2019-01-02T16:10:57-07:00 One suggestion is to reformat to put each parenthesis step on a separate line and put \ at the end of each line. That way, we might be able to understand better what you are doing.

Another help would be to put a numbered comment line above your whole command for each line of the reformatted command. That way we can understand better what each parenthesis section is supposed to be doing.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Command Produces Two FIles

Post by fmw42 »

That was not quite what I meant.

Write all the comments. Then write your commands in sections with line break \ at the end in short sections that fit on the page so that one does not have to scroll left right. You can break a parenthesis section into multiple parts with \ if needed.

#comment for line 1
#comment for line 2
#comment for line 3
...

Code: Select all

convert
\( parenthesis processing 1 \) \
\( parenthesis processing 2 \) \
other commands \
...
This would be more useful to me and how I do it. Other people write one setting or operator per line.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Command Produces Two FIles

Post by snibgo »

lindylex wrote:-annotate +30+0 "1/232">
What is that greater-than doing? Ending the command, and redirecting output to "-composite", I guess.
snibgo's IM pages: im.snibgo.com
lindylex
Posts: 23
Joined: 2014-02-27T16:36:22-07:00
Authentication code: 6789

Re: Command Produces Two FIles

Post by lindylex »

I do not want to pipe anything to -convert. I think that might not be correct.

I took it out and tried this.

Code: Select all

convert bgPapaer.jpg \( -size 950x950 -background "rgba(0,0,0,0)" -font /home/lex/share/Mo_De_Studio/audio_blog/OpenSans/OpenSans-ExtraBold.ttf -fill "#000000" caption:"$(cat ./temp.txt)" \( +clone -shadow 0x0+0+0 \) +swap -background "rgba(0,0,0,0)" -layers merge +repage \) -gravity center -composite -gravity northwest -pointsize 50 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +30+0 "1/232" -composite -gravity south -pointsize 40 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +0+10 "Robert Greene, Joost Elffers" r2.png
I receive this error ERROR .

Code: Select all

convert-im6.q16: no images defined `r2.png' @ error/convert.c/ConvertImageCommand/3258.
snibgo wrote: 2019-01-03T15:51:01-07:00
lindylex wrote:-annotate +30+0 "1/232">
What is that greater-than doing? Ending the command, and redirecting output to "-composite", I guess.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Command Produces Two FIles

Post by fmw42 »

You can do one of at least two simple things to fix your command line.

1) Separate it into multiple commands and show us the commands that work

2) If you cannot get separate commands to work, then put +write tmpX.png statements (X=1,2...N) after each operator and see if it is producing the right image at each stage.
lindylex
Posts: 23
Joined: 2014-02-27T16:36:22-07:00
Authentication code: 6789

Re: Command Produces Two FIles

Post by lindylex »

The command generate the image I want. It has an extra image that I do not want. This is what I want to resolve.

How do I do this? "+write tmpX.png statements"?
fmw42 wrote: 2019-01-03T17:58:39-07:00 You can do one of at least two simple things to fix your command line.

1) Separate it into multiple commands and show us the commands that work

2) If you cannot get separate commands to work, then put +write tmpX.png statements (X=1,2...N) after each operator and see if it is producing the right image at each stage.
lindylex
Posts: 23
Joined: 2014-02-27T16:36:22-07:00
Authentication code: 6789

Re: Command Produces Two FIles

Post by lindylex »

Code: Select all

convert bgPapaer.jpg \( -size 950x950 -background "rgba(0,0,0,0)" -font /home/lex/share/Mo_De_Studio/audio_blog/OpenSans/OpenSans-ExtraBold.ttf -fill "#000000" caption:"$(cat ./temp.txt)" \( +clone -shadow 0x0+0+0 \) +swap -background "rgba(0,0,0,0)" -layers merge +repage \) -gravity center -composite -gravity northwest -pointsize 50 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +30+0 "1/232" +write tmp1.png > -composite +write tmp2.png -gravity south -pointsize 40 -font /home/lex/share/python/ffmpegHelper/fonts/Typoster_ROCK_ON.otf -annotate +0+10 "Robert Greene, 
Joost Elffers" +write tmp3.png r2.png

This produces all the images along the way. All the command work. It produces this empty file still "-composite". I think it has to do with the > in the command here.

Code: Select all

-annotate +30+0 "1/232" +write tmp1.png > -composite 
If I take out the > it fails. Nothing about it looks right being there.
fmw42 wrote: 2019-01-03T17:58:39-07:00 You can do one of at least two simple things to fix your command line.

1) Separate it into multiple commands and show us the commands that work

2) If you cannot get separate commands to work, then put +write tmpX.png statements (X=1,2...N) after each operator and see if it is producing the right image at each stage.
lindylex
Posts: 23
Joined: 2014-02-27T16:36:22-07:00
Authentication code: 6789

Re: Command Produces Two FIles

Post by lindylex »

If this helps here is the command and the assets I am using. http://mo-de.net/d/hlp.zip
Post Reply