Page 1 of 1

How to splice on the right side instead of the left

Posted: 2008-11-18T05:14:31-07:00
by LunaEqualsLuna
I am trying to splice a white background onto an image i have using the splice command.

convert in.png -background white -splice 200x0 out.png

problem is this adds the white space to the left side and i want it on the right.

I tried messing around with the -gravity option

but the command

convert in.png -gravity East -background white -splice 200x0 out.png

gives an error
convert: geometry does not contain image `in.png'.

and does nothing to the image.

How do i splice on the right side?

Re: How to splice on the right side instead of the left

Posted: 2008-11-18T11:39:45-07:00
by fmw42
LunaEqualsLuna wrote:I am trying to splice a white background onto an image i have using the splice command.

convert in.png -background white -splice 200x0 out.png

problem is this adds the white space to the left side and i want it on the right.

I tried messing around with the -gravity option

but the command

convert in.png -gravity East -background white -splice 200x0 out.png

gives an error
convert: geometry does not contain image `in.png'.

and does nothing to the image.

How do i splice on the right side?

This works for me on IM 6.4.5-8 Q16

convert rose: -gravity east -background blue -splice 20x0 splice_right.gif


See if this works for you. What release are you using? Are you sure your input image is valid?

Re: How to splice on the right side instead of the left

Posted: 2008-11-18T17:16:33-07:00
by anthony
WARNING -spice should normally have a offset.
The command should be...

Code: Select all

  convert rose: -gravity east -background blue -splice 20x0+0+0 splice_right.gif
See IM examples, Splice...
http://www.imagemagick.org/Usage/crop/#splice

If you are interested. -splice was a comunity developed operator added in the early days of IM v6. For details see

Splice: Creating a New Image Operator
http://www.imagemagick.org/Usage/misc/#splice

Re: How to splice on the right side instead of the left

Posted: 2008-11-18T19:56:56-07:00
by fmw42
anthony wrote:WARNING -spice should normally have a offset.
The command should be...

Code: Select all

  convert rose: -gravity east -background blue -splice 20x0+0+0 splice_right.gif

Interesting as all of your examples, Anthony, with -gravity do not show offsets??? :?

I thought the offsets were optional and defaulted to +0+0. Is there some reason that this is not the case?

Re: How to splice on the right side instead of the left

Posted: 2008-11-18T20:00:34-07:00
by LunaEqualsLuna
This works for me on IM 6.4.5-8 Q16

convert rose: -gravity east -background blue -splice 20x0 splice_right.gif


See if this works for you. What release are you using? Are you sure your input image is valid?
I'm using 6.37 on linux.
I'm not sure what you mean by if the input image is valid though.
It is a normal image and and it works fine if i splice it on the left so i guess its valid :?
convert rose: -gravity east -background blue -splice 20x0+0+0 splice_right.gif
is that ':' supposed to be there? if i put that in it says it can't find the file 'in.png:' if i leave it off it gives the same error as before.

is there a workaround this? Can i like splice it on the left and then shift the image to the left? kind of weird that i can splice one side but not the other :?

Re: How to splice on the right side instead of the left

Posted: 2008-11-18T20:04:39-07:00
by fmw42
LunaEqualsLuna wrote:
This works for me on IM 6.4.5-8 Q16

convert rose: -gravity east -background blue -splice 20x0 splice_right.gif


See if this works for you. What release are you using? Are you sure your input image is valid?
I'm using 6.37 on linux.
I'm not sure what you mean by if the input image is valid though.
It is a normal image and and it works fine if i splice it on the left so i guess its valid :?
convert rose: -gravity east -background blue -splice 20x0+0+0 splice_right.gif
is that ':' supposed to be there? if i put that in it says it can't find the file 'in.png:' if i leave it off it gives the same error as before.
The rose is a special IM image and needs the colon. If you are getting an error saying in.png does not exist and it is not even in this command line, then you likely have a problem with your system or IM version.

Perhaps IM 6.3.7 had a bug with splice. Have you tried upgrading to the current version?

Re: How to splice on the right side instead of the left

Posted: 2008-11-18T20:21:14-07:00
by LunaEqualsLuna
fmw42 wrote:
LunaEqualsLuna wrote:
This works for me on IM 6.4.5-8 Q16

convert rose: -gravity east -background blue -splice 20x0 splice_right.gif


See if this works for you. What release are you using? Are you sure your input image is valid?
I'm using 6.37 on linux.
I'm not sure what you mean by if the input image is valid though.
It is a normal image and and it works fine if i splice it on the left so i guess its valid :?
convert rose: -gravity east -background blue -splice 20x0+0+0 splice_right.gif
is that ':' supposed to be there? if i put that in it says it can't find the file 'in.png:' if i leave it off it gives the same error as before.
The rose is a special IM image and needs the colon. If you are getting an error saying in.png does not exist and it is not even in this command line, then you likely have a problem with your system or IM version.

Perhaps IM 6.3.7 had a bug with splice. Have you tried upgrading to the current version?
I will probably try and download the latest version, a quick fix i've done is to rotate the image 180, splice it on the left then rotate it 180 again. Messy for sure, but for now it gets the job done since i'm in a hurry to get something done at the moment. I will check out the latest version and see if i still have this issue tho later.

interestingly i can splice the rose picture on the right side though, so there must be something up with the image i'm using,

edit

I've narrowed it down to using the mogrify -trim command. First i trim the image using mogrify trime, then if i try splice on the right i get an error. if i don't trim, it splices on the right as expected. Is there something else i need to know about mogrify -trim? that would cause this behaviour?

thx for your help!

Re: How to splice on the right side instead of the left

Posted: 2008-11-18T20:36:16-07:00
by LunaEqualsLuna
Well i sorta solved the problem myself on a hunch by using the -repage command while trimming.

I would be interested though in an explanation as to why NOT using -repage after trimming causes splicing on the right to fail but not the left... I don't like 'fixing' things without really knowing how i fixed them.

Re: How to splice on the right side instead of the left

Posted: 2008-11-18T21:48:15-07:00
by fmw42
LunaEqualsLuna wrote:Well i sorta solved the problem myself on a hunch by using the -repage command while trimming.

I would be interested though in an explanation as to why NOT using -repage after trimming causes splicing on the right to fail but not the left... I don't like 'fixing' things without really knowing how i fixed them.
+repage removes any virtual canvas that will occur if you use -crop. So you must use +repage after -crop.

Perhaps your original image had a virtual canvas to begin with. You could try:

convert in.png +repage -gravity East -background white -splice 200x0 out.png