Struggeling with running a big query

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
forumim

Struggeling with running a big query

Post by forumim »

Hy

I am confused with a long Query:

Code: Select all

convert original.jpg
-resize 1024x683 resized_original.jpg 
-size 1024x768 xc:#e3d4ef background_color.jpg -gravity northwest 
-composite original_on_background.jpg 
-crop 256x256 -quality 60 original_on_background.jpg  mytiles%02d.jpg
I would like:
Resize the original image:

Code: Select all

convert -resize 1024x683 resized_original.jpg 
Creating a background-image in a different size

Code: Select all

convert -size 1024x768 xc:#e3d4ef background_color.jpg
Putting the background-image and the resized-image together

Code: Select all

convert -gravity northwest -composite original_on_background.jpg 
Cutting tiles from the final image (original_on_background.jpg)

Code: Select all

convert -crop 256x256 -quality 60 original_on_background.jpg  mytiles%02d.jpg
Every sigle qery works great.
But when I put together the 4 queries it doesent work.
The original_on_background.jpg ist not what it sholud be. I don't understad what happend exactly.

Mabe it is not possible to work with such big queries.
Mabe i need to run each query in a single way.

(I run the query in PHP: exec(my-query). I think, it is better to run one query than four. Isn't it?)

Aperciate any help, I would like to understand....
Schorsch
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Struggeling with running a big query

Post by el_supremo »

Try this:

Code: Select all

convert -size 1024x768 xc:#e3d4ef ( original.jpg -resize 1024x683 ) -gravity northwest \
   -composite -crop 256x256 -quality 60 mytiles%02d.jpg
Pete
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Struggeling with running a big query

Post by Bonzo »

Slightly different method mentioned by Anthony

Code: Select all

<?php
exec("convert ( input.jpg -resize 1024x683 ) -background #e3d4ef -extent 1024x768 -crop 256x256 -quality 60 mytiles%02d.jpg");
?>
forumim

Re: Struggeling with running a big query

Post by forumim »

This works:

Code: Select all

exec("convert input.jpg -resize 1024x683 output.jpg", $arr, $err);
This doesn't work:

Code: Select all

exec("convert (input.jpg -resize 1024x683) output.jpg", $arr, $err);
Error: 2
Version: ImageMagick 6.2.8 04/17/08 Q16

Any idea, why (...) -stuff doesen't work?

Schorsch
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Struggeling with running a big query

Post by Bonzo »

Couple of things to try

Note spaces

Code: Select all

( input.jpg -resize 1024x683 )
Escape the ( )

Code: Select all

/(input.jpg -resize 1024x683/)
forumim

Re: Struggeling with running a big query

Post by forumim »

Thanks! Problem solved:

Code: Select all

exec("convert \( image.jpg -resize 1024x683 \) -background red -extent 1024x768 -crop 256x256 -quality 60 mytiles%02d.jpg", $arr, $err );
but

Code: Select all

-background red 
doesen't work.
It is always black. Dosen't matter, which color I define.

Other Question:

Code: Select all

mytiles%02d.jpg
Can I save the tile-images, so that the images on the first line are named:
mytiles1-00.jpg, mytiles1-01.jpg, mytiles1-02.jpg...

And the tiles on the second line:
mytiles2-00.jpg, mytiles2-01.jpg, mytiles2-02.jpg...

And so on...
Post Reply