Page 1 of 1
creating multiple images fails
Posted: 2012-06-29T12:55:48-07:00
by qwertywin
So I am using IM4JAVA to create a commandline call and it outputs the following, now problem is even though I tell imagemagick to force the size (-resize WxH!) it still does not do exactly what it is told, highly confusing.
I have moved each sub operation onto a new line for readability.
Code: Select all
convert /tmp/image1.jpg -colorspace RGB
( +clone -filter Lanczos -resize 300x200! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_F.jpg +delete )
( +clone -filter Lanczos -resize 600x400! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_Z.jpg +delete )
( +clone -filter Lanczos -resize 100x67! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_B.jpg +delete )
( +clone -filter Lanczos -resize 800x530! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_P.jpg +delete )
( +clone -crop 4400x3350+310+0 -filter Lanczos -resize 120x90! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_Q.jpg +delete )
( +clone -filter Lanczos -resize 400x270! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_M.jpg +delete )
( +clone -filter Lanczos -resize 384x260! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_I.jpg +delete )
( +clone -filter Lanczos -resize 480x320! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_J.jpg +delete )
( +clone -filter Lanczos -resize 560x370! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04.jpg +delete )
( +clone -filter Lanczos -resize 300x300! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_G.jpg +delete )
( +clone -filter Lanczos -resize 2048x1400! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_S.jpg +delete )
( +clone -crop 3400x3350+810+0 -filter Lanczos -resize 70x70! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_A.jpg +delete )
( +clone -filter Lanczos -resize 350x230! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_H.jpg +delete )
( +clone -filter Lanczos -resize 150x100! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_C.jpg +delete )
( +clone -filter Lanczos -resize 1024x680! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_R.jpg +delete )
( +clone -filter Lanczos -resize 250x170! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /mnt/media/data/3/0/33/206/753/FEATR_FITN_04_E.jpg +delete )
-filter Lanczos -resize 200x130! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB /mnt/media/data/imageRepo/3/0/33/206/753/FEATR_FITN_04_D.jpg
Re: creating multiple images fails
Posted: 2012-06-29T13:07:15-07:00
by Bonzo
The +clone will simply make a copy of the last image in the image sequence, and is thus equivalent to using a argument of '−1'.
Is this your intention?
Re: creating multiple images fails
Posted: 2012-06-29T13:23:22-07:00
by qwertywin
yes, I want use the first "original" image and create multiple sizes different sizes from it, unless im wrong (which wouldnt surprise me) I believe this is the way to do it as
+clone, should clone the image from the stack (the original image) then -write will put my new image on the stack, then +delete will that new image from the stack, so the next sub command can +clone the original image again.
Re: creating multiple images fails
Posted: 2012-06-29T13:30:41-07:00
by Bonzo
You could be correct I have not tried it. This may be a neater way
This method again saves the tempory image into the memory; you can call the image whatever you like - in this case its called image. Once the image is saved into the memory you can call it as many times as you like.
Code: Select all
convert input.jpg -write mpr:image +delete
( mpr:image -thumbnail x480 -write 480_wide.jpg )
( mpr:image -thumbnail x250 -write 250_wide.jpg )
( mpr:image -thumbnail x100 -write 100_wide.jpg )
( mpr:image -thumbnail 64x64! -write 64_square.jpg )
( mpr:image -colorspace Gray -write black_white.jpg )
-clone 0 would also have worked instead of +clone
It would be interesting to know what is being output against what you want.
In your example I think you are supposed to have a null: at the end although I found in some cases it caused the code to fail.
Re: creating multiple images fails
Posted: 2012-06-29T13:42:15-07:00
by qwertywin
the major problem I have is the results are completely unexpected and differ, mainly because the order of the commands is different per invocation also.
I'll see if i can do it the way you proposed with im4java
Re: creating multiple images fails
Posted: 2012-06-29T14:27:28-07:00
by fmw42
qwertywin wrote:yes, I want use the first "original" image and create multiple sizes different sizes from it, unless im wrong (which wouldnt surprise me) I believe this is the way to do it as
+clone, should clone the image from the stack (the original image) then -write will put my new image on the stack, then +delete will that new image from the stack, so the next sub command can +clone the original image again.
You command is cloning the previous image and not the original. To clone the original in each step use -clone 0 not +clone.
Re: creating multiple images fails
Posted: 2012-06-29T15:20:59-07:00
by qwertywin
well that was dumb of me.
i moved to using mpr:image method
Code: Select all
convert input.jpg -write mpr:image +delete
( mpr:image -thumbnail x480 -write 480_wide.jpg )
( mpr:image -thumbnail x250 -write 250_wide.jpg )
( mpr:image -thumbnail x100 -write 100_wide.jpg )
( mpr:image -thumbnail 64x64! -write 64_square.jpg )
( mpr:image -colorspace Gray -write black_white.jpg )
except it gives me an error "unbalanced parenthesis" in windows or "unexpected token '(' in linux,
Bonzo mention i probably need a null: but i am not sure what he is referring too.
Re: creating multiple images fails
Posted: 2012-06-29T15:39:03-07:00
by fmw42
convert input.jpg -write mpr:image +delete ^
( mpr:image -thumbnail x480 -write 480_wide.jpg ) ^
( mpr:image -thumbnail x250 -write 250_wide.jpg ) ^
( mpr:image -thumbnail x100 -write 100_wide.jpg ) ^
( mpr:image -thumbnail 64x64! -write 64_square.jpg ) ^
( mpr:image -colorspace Gray -write black_white.jpg ) null:
That is because you always need an output and you do not have any besides the ones after -write, thus there is no output. So you need to add a null output. Note if you break lines (lf or cr), i.e, it is not all one long command on the same line, you must put a new line character at the end before the break (no spaces after it)
This should be the same using clones
convert input.jpg ^
( -clone 0 -thumbnail x480 -write 480_wide.jpg ) ^
( -clone 0 -thumbnail x250 -write 250_wide.jpg ) ^
( -clone 0 -thumbnail x100 -write 100_wide.jpg ) ^
( -clone 0 -thumbnail 64x64! -write 64_square.jpg ) ^
( -clone 0 -colorspace Gray -write black_white.jpg ) null:
Re: creating multiple images fails
Posted: 2012-06-29T15:46:34-07:00
by qwertywin
awesome! that makes perfect sense.
now another issue, the last image i try to create never gets created:
Code: Select all
convert 44966473.jpg -colorspace RGB -write mpr:image +delete
( mpr:image -filter Lanczos -resize 670x480! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_P.jpg )
( mpr:image -filter Lanczos -resize 150x110! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_C.jpg )
( mpr:image -filter Lanczos -resize 560x400! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_Z.jpg )
( mpr:image -crop 420x423+95+0 -filter Lanczos -resize 70x70! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_A.jpg )
( mpr:image -filter Lanczos -resize 560x400! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22.jpg )
( mpr:image -filter Lanczos -resize 300x300! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_G.jpg )
( mpr:image -filter Lanczos -resize 200x140! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_D.jpg )
( mpr:image -filter Lanczos -resize 384x270! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_I.jpg )
( mpr:image -filter Lanczos -resize 300x210! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_F.jpg )
( mpr:image -filter Lanczos -resize 350x250! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_H.jpg )
( mpr:image -filter Lanczos -resize 400x290! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_M.jpg )
( mpr:image -filter Lanczos -resize 100x71! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_B.jpg )
( mpr:image -filter Lanczos -resize 250x180! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_E.jpg )
( mpr:image -filter Lanczos -resize 480x340! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB -write /images/3/0/44/966/472/msyri_phototour22_J.jpg )
( mpr:image -crop 550x423+30+0 -filter Lanczos -resize 120x90! -format JPEG -compress Lossless -quality 85.0 -colorspace RGB /images/3/0/44/966/472/msyri_phototour22_Q.jpg ) null:
so when you run it it says:
linux: convert: unable to open image `/images/3/0/44/966/472/msyri_phototour22_Q.jpg': @ error/blob.c/OpenBlob/2588.
windows: convert.exe: unable to open image `C:\images\3\0\44\966\472\msyri_phototour22_Q.jpg': No such file or directory @ error/blob.c/OpenBlob/2614.
all the other images are generated as expected.
Re: creating multiple images fails
Posted: 2012-06-29T15:51:09-07:00
by fmw42
I still don't see the null: in your code! Your last parenthesis has no -write. If you want the last line to generate the last image, you need to use the -clone 0 method and leave off the last parenthesis and then no null: is required, if there is no -write in the last line. However, the proper method is to keep the parens, the last write and end with a null: with either mpr or clones.
-compress lossless is probably useless as your giving it a quality value of less than 100 and even with 100, jpg will be lossy.
see -compress none or +compress
http://www.imagemagick.org/script/comma ... p#compress
Re: creating multiple images fails
Posted: 2012-06-29T15:54:15-07:00
by qwertywin
sorry it is there, I just was reformatting it so it was readable! (ive added it in now!)
thanks I dumbly copied that part about loseless.
Re: creating multiple images fails
Posted: 2012-06-29T15:56:25-07:00
by fmw42
qwertywin wrote:sorry it is there, I just was reformatting it so it was readable! (ive added it in now!)
thanks I dumbly copied that part about loseless.
see my last edit above about needing a -write in the last paren as well as the null: afterwards.
Re: creating multiple images fails
Posted: 2012-06-29T16:02:14-07:00
by qwertywin
not quite solved yet
so the last image in the command ends up with 16 sizes
/images/3/0/44/966/472/msyri_phototour22_J.jpg
/images/3/0/44/966/472/msyri_phototour22_J-0.jpg
/images/3/0/44/966/472/msyri_phototour22_J-1.jpg
/images/3/0/44/966/472/msyri_phototour22_J-2.jpg
/images/3/0/44/966/472/msyri_phototour22_J-3.jpg
.....
/images/3/0/44/966/472/msyri_phototour22_J-15.jpg
this is under windows,
###### looks like it only does this in windows ########
linux is fine.
Re: creating multiple images fails
Posted: 2012-06-29T16:38:35-07:00
by fmw42
If you corrected code above is what you used, you still left off the -write in the last line which is probably why you are getting multiple images.
I need to see your command, but please put each paren on a separate line with ^ at the end (in windows) so that it is more readable. In unix each paren needs \ as an escape as \( ... \) and the end of line character is \
Alternately, try the simpler commands (with mpr or clone) as recommended above to test the concept with any reasonable image. See if that works fine.
Re: creating multiple images fails
Posted: 2012-07-04T18:26:52-07:00
by anthony
qwertywin wrote:yes, I want use the first "original" image and create multiple sizes different sizes from it, unless im wrong (which wouldnt surprise me) I believe this is the way to do it as
+clone, should clone the image from the stack (the original image) then -write will put my new image on the stack, then +delete will that new image from the stack, so the next sub command can +clone the original image again.
But the original image is the 'first' image in the list... NOT the last image whcih was the image from the previous parenthesis.
Use
-clone 0 instead for the original image!