Page 1 of 1
Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-15T21:11:04-07:00
by kiwijunglist
Hi
I'm trying to use imagemagick for auto creating missing disc images from a movie poster for mediaportal (open source home theatre pc software). I'm hoping some one can help me with the commands I need to use.
Start with poster.jpg which is a rectangular image and can be any size.
Step 1a - Centre crop into a square
Step 1b - Resize to 1000 x 1000
Step 2 - Apply a transparency mask
Step 3 - Overlay a semi transparent image on top
Save final image as png with transparency
Link to poster.jpg/transperncy masks etc on photobucket
Link to .zip file with all images
Any help will be appreciated. I'm trying to do this myself but I'm struggling, hopefully this is a relatively simple task for most people and someone can chime in with the steps I need to do
Thanks!!! <3
Re: Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-15T21:46:52-07:00
by fmw42
try this (unix commands)
convert poster.jpg -gravity center -crop 1000x1000+0+0 +repage \
dvdoverlay.png -compose over -composite \
transparency_mask.png -alpha off -compose copy_opacity -composite result.png
if on windows replace line continuation \ with ^
see
http://www.imagemagick.org/Usage/crop/
http://www.imagemagick.org/Usage/compose/
Re: Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-15T21:55:32-07:00
by kiwijunglist
THANKS!
That is 95% there
I actually want to apply the mask before the overlay, I might be able to figure this out myself (hopefully)
EDIT:
convert poster.jpg -gravity center -crop 1000x1000+0+0 +repage ^ transparency_mask.png -alpha off -compose copy_opacity -composite dvdoverlay.png -compose over -composite ^ result.png
It works, THANK YOU x 1000 ! <3 <3 you saved me many hours of work
Re: Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-15T22:01:27-07:00
by fmw42
kiwijunglist wrote:THANKS!
That is 95% there
I actually want to apply the mask before the overlay
Why if this gets the result you want?
Re: Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-15T22:02:21-07:00
by kiwijunglist
thanks, i switched the order of the commands (as above edited post) and i got the result i wanted
(There was some shadowing outside the dvdoverlay image that was cut off by the mask, if you applied the mask first)
Re: Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-15T22:13:31-07:00
by fmw42
kiwijunglist wrote:thanks, i switched the order of the commands (as above edited post) and i got the result i wanted
(There was some shadowing outside the dvdoverlay image that was cut off by the mask, if you applied the mask first)
OK. Glad you solved it.
Re: Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-15T22:25:23-07:00
by kiwijunglist
There is a small problem with the resize / crop in the first part of the command
convert poster.jpg -gravity center -crop 1000x1000+0+0 +repage result.jpg
What seems to be happening is it is croping a 1000x1000 centre part of the image, but what I really want is
Resize the width to 1000 pixels while maintaining the aspect ratio, and then center crop to 1000x1000 discarding part of the top + bottom of the image
see below
I'll try figure it out using those links you gave me
Re: Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-15T22:56:51-07:00
by kiwijunglist
Unfortunately I wasn't able to figure out the code to do what I wanted...
however I figured out a cheat
Since all the movie posters have an aspect ratio of 0.667 If I resize to 1500x1500 then the width will be exactly 1000 pixels
convert poster.jpg -resize 1500x1500 ^ -gravity center -crop 1000x1000+0+0 +repage result.jpg
Re: Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-16T10:32:44-07:00
by fmw42
kiwijunglist wrote:Unfortunately I wasn't able to figure out the code to do what I wanted...
however I figured out a cheat
Since all the movie posters have an aspect ratio of 0.667 If I resize to 1500x1500 then the width will be exactly 1000 pixels
convert poster.jpg -resize 1500x1500 ^ -gravity center -crop 1000x1000+0+0 +repage result.jpg
convert poster.jpg -resize 1500x1500 ^ -gravity center -crop 1000x1000+0+0 +repage result.jpg
is exactly the correct command
Re: Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-16T19:43:31-07:00
by anthony
You want to not only crop the image but resize it too.
See thumbnails. Cut thumbnail to fit...
http://www.imagemagick.org/Usage/thumbnails/#cut
The trick here is to use a special flag for the resize to resize the smaller dimension rather than the larger.
(fit around the given size rather inside the given size).
See also resize, Fill Area Flag ('^' flag)
http://www.imagemagick.org/Usage/resize/#fill
NOTE there is NO space between the numbers and the flag! and under windows you need to double up that flag!
Re: Resize -> Crop -> Image Mask -> Merge Layers
Posted: 2012-10-16T19:56:42-07:00
by fmw42
NOTE there is NO space between the numbers and the flag! and under windows you need to double up that flag!
Anthony is quite correct. I missed the space before the ^. Sorry about that. Also I was not aware of your being on Windows. So if that is so, there are syntax differences as Anthony points out. For more details see
http://www.imagemagick.org/Usage/windows/