Page 1 of 1

Composite portrait image over blur version of same image

Posted: 2019-03-25T11:32:12-07:00
by FastBill
Using ImageMagick 6.9.6-6 Q16 x86_64 2016-12-24, I'm trying to make photos shot with portrait orientation appropriate for TV by superimposing each image over wider, blurred copies of the same image. I'm running on macOS 10.12.6 (Sierra) on a 2012 iMac. I've written a shell script to perform this operation upon every image in a directory. For some images, the script does what is expected, but for other images the results are incorrect.

Here is a link to a folder in my Dropbox: https://www.dropbox.com/sh/1o7i91bt4v9x ... wFala?dl=0. Photo 1-Flowers.png is an original photo in portrait orientation. Photo 2-Flowers-blur.png shows the result created by my shell script. The script placed enlarged, blurred copies of the original photo on the left and right sides, so that the resulting composite photo is now in landscape orientation.

Photo 3-Lab.jpg is another original portrait-oriented photo, and Photo 4-Lab-blur.jpg shows the result created by my shell script. Rather than placing the enlarged, blurred copies on the sides, the shell script placed these copies above and below the original.

Here is my shell script:

Code: Select all

#!/bin/sh
for f in ./*.*
do
	echo $f
convert "$f" \( -clone 0 -resize 200% -blur 0x37 -gravity center -crop x50%+0+0 +repage \) \( -clone 0 \) -delete 0 -gravity center -compose over -composite -set filename:fname %t_blur.%e  ../_originals/%[filename:fname]
done
I would appreciate any assistance with understanding why this script behaves as it does, and how to modify it so that it performs reliably on every portrait-oriented image.

Thanks,
FastBill

Re: Composite portrait image over blur version of same image

Posted: 2019-03-25T12:26:23-07:00
by snibgo

Code: Select all

f:\web\im\fori>%IM%identify 3-Lab.jpg
3-Lab.jpg JPEG 3008x2008 3008x2008+0+0 8-bit sRGB 2.22205MiB 0.047u 0:00.047
So, 3-Lab.jpg is wider than it is high, which isn't "portrait format".

The problem is that the image is 3008x2008, but with exif metadata that says this should be rotated by 90 degrees. So insert "-auto-orient" after reading the input. See http://www.imagemagick.org/script/comma ... uto-orient