help

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
dev.alex89
Posts: 12
Joined: 2011-07-03T04:02:30-07:00
Authentication code: 8675308

help

Post by dev.alex89 »

command runs slowly: ~ 8 seconds

/usr/bin/convert 'FIRST_IMG' \( -resize 270x265! -crop 270x265 -level -10% -matte -virtual-pixel transparent -distort Perspective '0,0,1,1 0,265,0,264 265,0,260,72 265,260,268,236' 'ANOTHER_IMG' \) -background none -geometry +177+186 -compose Atop -composite 'RESULT_IMG'

FIRST_IMG - jpeg (The JPEG image format) 600px × 480px
ANOTHER_IMG - PNG Image - 800px × 600px

Why so slow, what to do to make it faster?

Server ubuntu-x86_64 500 Mhz RAM 256 Mb
PHP Version 5.3.3-1ubuntu9.5
ImageMagick 6.6.2-6 2010-12-02 Q16
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: help

Post by fmw42 »

/usr/bin/convert 'FIRST_IMG' \( -resize 270x265! -crop 270x265 -level -10% -matte -virtual-pixel transparent -distort Perspective '0,0,1,1 0,265,0,264 265,0,260,72 265,260,268,236' 'ANOTHER_IMG' \) -background none -geometry +177+186 -compose Atop -composite 'RESULT_IMG'
Not sure exactly what you are doing, but your syntax is off. you need to add a clone inside your parenthesis

/usr/bin/convert 'FIRST_IMG' \( +clone -resize 270x265! -crop 270x265 -level -10% -matte -virtual-pixel transparent -distort Perspective '0,0,1,1 0,265,0,264 265,0,260,72 265,260,268,236' 'ANOTHER_IMG' \) -background none -geometry +177+186 -compose Atop -composite 'RESULT_IMG'


What is 'ANOTHER_IMG'? Is that an output or another input? If another input, then replace +clone with 'ANOTHER_IMG' at the beginning of the parenthesis (input images are specified first).


/usr/bin/convert 'FIRST_IMG' \( 'ANOTHER_IMG' -resize 270x265! -crop 270x265 -level -10% -matte -virtual-pixel transparent -distort Perspective '0,0,1,1 0,265,0,264 265,0,260,72 265,260,268,236' \) -background none -geometry +177+186 -compose Atop -composite 'RESULT_IMG'
dev.alex89
Posts: 12
Joined: 2011-07-03T04:02:30-07:00
Authentication code: 8675308

Re: help

Post by dev.alex89 »

Thanks for the reply, that's what I'm doing:
Image
I need to insert one image into another, and to first apply several effects, before do resizing and cropping.

FIRST_IMG is LOUIS VUITTON
ANOTHER_IMG is dolphins.jpg (img inside FIRST_IMG)

Maybe I'm wrong wrote the command, how to write correctly?
I'll try those options that you have written
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: help

Post by fmw42 »

try this one -- I believe this is correct for what you describe.

/usr/bin/convert 'FIRST_IMG' \( 'ANOTHER_IMG' -resize 270x265! -crop 270x265 -level -10% -matte -virtual-pixel transparent -distort Perspective '0,0,1,1 0,265,0,264 265,0,260,72 265,260,268,236' \) -background none -geometry +177+186 -compose Atop -composite 'RESULT_IMG'
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: help

Post by anthony »

If you use +distort with the exact coordinates you want, you can then simply use -flatten or other layer operator to overlay the distorted image onto the background image.

However I would first remove any barrel or other lens distortion from the image, as that will ensure any straight lines in the image is actually straight.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply