Don't know how to fill background of image

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
User avatar
monkey
Posts: 4
Joined: 2011-10-23T04:47:25-07:00
Authentication code: 8675308

Don't know how to fill background of image

Post by monkey »

Hello people!
First of all I'm new here, I'm also new to ubuntu commands and creating .sh scripts. I'm using a script made by a user that allows you to create thumbnails from a video, here's the code: http://cli-apps.org/CONTENT/content-files/74676-shot.
I've searched high and low and I found a couple of topics about the bg color but I don't know where to put the convert line.
I've used:
convert source -background "#ddddff" target
right before this line: convert "$file_name".jpg -quality $quality -splice 0x80 -draw 'image over 5,5 0,0 text.jpg' "$path/$file_name".jpg (it's located almost at the bottom of the page) and it filled only the top of the picture, leaving the text background and the space between stills white.

Like I said, I'm new to this kind of stuff and I would really appreciate a little help from you guys.
Thank you.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Don't know how to fill background of image

Post by fmw42 »

can you explain functionally what you want to do? can you provide a link to an image and tell us what you want to change in it?

-background some color

is just a setting for other operators. If you want to change the background color of some image, you probably need to floodfill it from the outside with some fuzz value to allow it to change the color if it is not a solid color but has some variation.

But it is hard to tell you what to do without really understanding your problem from a simple point of view of processing one image. Your script is rather complex and no one probably wants to figure out what it is doing.


see
http://www.imagemagick.org/Usage/draw/#color
http://www.imagemagick.org/script/comma ... s.php#fuzz
User avatar
monkey
Posts: 4
Joined: 2011-10-23T04:47:25-07:00
Authentication code: 8675308

Re: Don't know how to fill background of image

Post by monkey »

I'm sorry about that, forgot to say the script creates thumbnails of a video file and it depends on mplayer and imagemagick.

Here's what the picture looks like with default background color (the script is unchanged):
http://imageshack.us/f/804/59046114.jpg/
And this is what I get if I add convert source -background color target:
http://imageshack.us/f/835/ushercaughtuphq.jpg/

There's the problem, it doesn't fill the whole background. Default color remains behind video info text and between thumbnails.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Don't know how to fill background of image

Post by Bonzo »

I would guess you need to change the background colour in two other locations as well.

This line creats the text image and I would try adding a background colour:

Code: Select all

echo -e "File name: $file_name_ext\nSize: $size Mb\nResolution: $format\nDuration: $length min." | convert -background red -pointsize 16 -trim +repage text:- text.jpg
I think this line creates the screen shots so try adding a background there as well:

Code: Select all

montage -background red -geometry +2+2 `ls *.png | sort -n` "$file_name".jpg
User avatar
monkey
Posts: 4
Joined: 2011-10-23T04:47:25-07:00
Authentication code: 8675308

Re: Don't know how to fill background of image

Post by monkey »

Bonzo, a heart full of thanks for your help. Those were exactly the two things I was missing.
As you said, the first one is for the text background, the second one is for the space between the shots and the last one is for the remaining space.
It creates separate layers (text, thumbnails, etc) and then merges them.

Thanks again for your help.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Don't know how to fill background of image

Post by Bonzo »

Its good you are sorted - on another subject the tempory images are saved as jpg; saving them as png or miff should improve your final image quality. Worth a test ?
User avatar
monkey
Posts: 4
Joined: 2011-10-23T04:47:25-07:00
Authentication code: 8675308

Re: Don't know how to fill background of image

Post by monkey »

The conversion from png to jpg is a good thing (in my case) because I want my images to be compressed, the less file size the better.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Don't know how to fill background of image

Post by anthony »

Fir the final image yes. But intermediate temporary images, using a Lossy Compression File format is NOT a good idea.
The more time you save to JPEG the more data lost you will get.

It is only temporary any way, and such data is typically saved for just for a few seconds on a separate 'work in progress' area (usually "/tmp").


What ever you do do, preserve the original and always work from the original is possible.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply