composte multiple images + contrast the background

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?".
Post Reply
Andy
Posts: 30
Joined: 2014-03-23T03:06:04-07:00
Authentication code: 6789

composte multiple images + contrast the background

Post by Andy »

Hi,

i create the following call to create a gif in the end.
A little background: The part \( \) appears multiple times in the final call to create the gif but for this example i added just one.

Code: Select all

convert -quiet \( -brightness-contrast 16x14 background.png  text_1.png  -geometry +50+50 -composite text_2.png -geometry +200+200 -composite \) playr_1511713518.gif
This works as expected. A gif is created with the main image background.png and two texts. The problem is, the first text "text_1.png -geometry +50+50 -composite" is effected by the "-brightness-contrast 16x14" command and i can't find a place to put "-brightness-contrast 16x14" so it doesn't happen.

Would be nice to get some advice on how to change it so it will work.

Cheers,
Andy
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: composte multiple images + contrast the background

Post by fmw42 »

Please always specify your IM version and platform. If you can provide the input images and your output image, we can help further. You can upload to any free hosting service (such as dropbox.com) and put your URLs here.

Note that commands such as -brightness-contrast and settings need to come after reading images. Also you should do composites in pairs with parentheses around them. So I think your issue is a combination of the two. I am not sure which image or composite the brightness-contrast should apply. Is it text_1.png or background.png or the composite of the two. Perhaps if you provide more details about what you want to do functionally, we can help further.
Andy
Posts: 30
Joined: 2014-03-23T03:06:04-07:00
Authentication code: 6789

Re: composte multiple images + contrast the background

Post by Andy »

fmw42 wrote: 2017-11-26T11:39:14-07:00 Please always specify your IM version and platform. If you can provide the input images and your output image, we can help further. You can upload to any free hosting service (such as dropbox.com) and put your URLs here.
Sorry about that, i thought this might not be necessary in this case cause it's not image specific but if you still need them i will add them later. For now i will just answer your other questions.
*edit Here are the images: https://imgur.com/a/jnOoj
fmw42 wrote: 2017-11-26T11:39:14-07:00 Note that commands such as -brightness-contrast and settings need to come after reading images. Also you should do composites in pairs with parentheses around them. So I think your issue is a combination of the two. I am not sure which image or composite the brightness-contrast should apply. Is it text_1.png or background.png or the composite of the two. Perhaps if you provide more details about what you want to do functionally, we can help further.
Well, i am not sure how that would look.
If you look at the call in my first post, I want to combine the three images and specific settings should only be applied to the base image, background.png in my example. So the setting "-brightness-contrast 16x14" Should only be applied to "background.png" and after that the two other images should be composited onto the base image.

In the end everything should be combined as a final gif. This all already works just the settings are applied wrongly.

Here an example with multiple background images so a gif actually makes sense. :)

Code: Select all

convert -quiet 
\( -brightness-contrast 16x14 background.png  text_1.png  -geometry +50+50 -composite text_2.png -geometry +200+200 -composite \) 
\( -brightness-contrast 16x14 background2.png  text_1.png  -geometry +50+50 -composite text_2.png -geometry +200+200 -composite \) 
\( -brightness-contrast 16x14 background3.png  text_1.png  -geometry +50+50 -composite text_2.png -geometry +200+200 -composite \) 
\( -brightness-contrast 16x14 background4.png  text_1.png  -geometry +50+50 -composite text_2.png -geometry +200+200 -composite \) 
\( -brightness-contrast 16x14 background5.png  text_1.png  -geometry +50+50 -composite text_2.png -geometry +200+200 -composite \) 
...
playr_1511713518.gif
Hope that clears is up and please let me know if you need anything else.

Here are my system informations:
$ convert --help
Version: ImageMagick 6.9.9-23 Q16 x86_64 2017-11-12 http://www.imagemagick.org

OS: Archlinux, 64bit
Thx for your time
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: composte multiple images + contrast the background

Post by fmw42 »

Actually, it is Imagemagick specific, since you are using ImageMagick commands. Furthermore, there could be issue will versions or syntax differences between Unix and Windows systems or syntax difference between IM 6 and IM 7.

Try this

Code: Select all

convert -quiet \
\( background.png -brightness-contrast 16x14 \) \
text_1.png  -geometry +50+50 -composite \
text_2.png -geometry +200+200 -composite \
playr_1511713518.gif
Andy
Posts: 30
Joined: 2014-03-23T03:06:04-07:00
Authentication code: 6789

Re: composte multiple images + contrast the background

Post by Andy »

Awesome with your hint i managed to get it:

This works like a charm.

Code: Select all

convert -quiet \
\( \(  background.png -brightness-contrast 16x14 \) \
text_1.png  -geometry +50+50 -composite \
text_2.png -geometry +200+200 -composite \)\
\( \(  background.png -brightness-contrast 16x14 \) \
text_1.png  -geometry +50+50 -composite \
text_2.png -geometry +200+200 -composite \)\
\( \(  background.png -brightness-contrast 16x14 \) \
text_1.png  -geometry +50+50 -composite \
text_2.png -geometry +200+200 -composite \)\
(...)
playr_1511713518.gif
Thx a lot and a nice rest weekend!
Post Reply