Page 1 of 1
fraction cropping and hex creating?
Posted: 2009-08-23T04:32:12-07:00
by haibara
here i have a image whose size is 300x300, i want to get little 100x100 images?
how can i use crop parameter to support fraction cropping?
convert -crop 33.333333...%x33.333333...% [src] [dst]
??????
the second question is about xc?
formly, i always use 'convert -size 800x600 xc:#00000000 png32:result.png' to create a rgba png. why prompt new im error?
regards
Re: fraction cropping and hex creating?
Posted: 2009-08-23T11:13:45-07:00
by fmw42
haibara wrote:here i have a image whose size is 300x300, i want to get little 100x100 images?
how can i use crop parameter to support fraction cropping?
convert -crop 33.333333...%x33.333333...% [src] [dst]
??????
the second question is about xc?
formly, i always use 'convert -size 800x600 xc:#00000000 png32:result.png' to create a rgba png. why prompt new im error?
regards
1)
use [src] -gravity center -crop 100x100+0+0 +repage [dst]
to get exactly 100x100. Using percent is not recommened as you will not get exactly the size you want.
2) you have to put hex colors in quotes
convert -size 800x600 xc:"#00000000" png32:result.png
or
convert -size 800x600 xc:'#00000000' png32:result.png
any non-name color must be put in quotes, so similarly with rgb(0,0,0) needs to be put in quotes
Re: fraction cropping and hex creating?
Posted: 2009-08-23T21:28:06-07:00
by haibara
fmw42 wrote:
1)
use [src] -gravity center -crop 100x100+0+0 +repage [dst]
to get exactly 100x100. Using percent is not recommened as you will not get exactly the size you want.
2) you have to put hex colors in quotes
convert -size 800x600 xc:"#00000000" png32:result.png
or
convert -size 800x600 xc:'#00000000' png32:result.png
any non-name color must be put in quotes, so similarly with rgb(0,0,0) needs to be put in quotes
thanks
1), sometimes i don't know extract size, i only know cropping count
-crop can support integer percent, why can't support fraction(IM limited?)?
2), after adding quote, it still has a problem: the produced png is only 2-bit!
Re: fraction cropping and hex creating?
Posted: 2009-08-23T21:58:34-07:00
by fmw42
haibara wrote:
1), sometimes i don't know extract size, i only know cropping count
-crop can support integer percent, why can't support fraction(IM limited?)?
2), after adding quote, it still has a problem: the produced png is only 2-bit!
you can use fractional percent, but images are digital and you will get them trucated or rounded to an integer number in width or height
convert [src] -crop 33.33%x33.33%+0+0 +repage [dst]
You either need to set the offset from +0+0 or use -gravity center or -gravity ... to reference the base location from which the offset is measured
see
http://www.imagemagick.org/script/comma ... s.php#crop
http://www.imagemagick.org/script/comma ... p#geometry
should work
your xc:'#00000000' sets the color to transparent black. As IM knows you only have black it sets the bit depth to 1 bit. There is no reason to have more depth.
Re: fraction cropping and hex creating?
Posted: 2009-08-23T22:58:24-07:00
by anthony
To generate tiles leave off the positional component (EG the +0+0) part.
Also if the image is not divisible by 3 the last image in each row/column may be short.
For example if you have a 100 pixel image and you divided by 3 you get 33 pixels
That will generate 4 tiles of 33,33,33,1
where if you use 34 images for the tiles you get 34,34,32 pixel images.
I have a proposal and the math worked out to divide an image into 3 parts as equally as possible. That is for a 100 pixel raneg it will divide the image into sizes 33,34,33
The math even allows for a constant overlap between tiled components. It just needs to be implemented into the ImageMagick library.
See
http://www.imagemagick.org/Usage/bugs/f ... b-division
Re: fraction cropping and hex creating?
Posted: 2009-08-24T01:29:10-07:00
by haibara
about fraction cropping, i see.
i have to report my fault, only running "convert -size 800x600 xc:'#00000000' result.png" will produce 2-bit png, if adding "png32:" will produce normal png.
and another question, how can i use xc(with hex) to create 8-bit png?
Re: fraction cropping and hex creating?
Posted: 2009-08-24T10:22:22-07:00
by fmw42
haibara wrote:about fraction cropping, i see.
i have to report my fault, only running "convert -size 800x600 xc:'#00000000' result.png" will produce 2-bit png, if adding "png32:" will produce normal png.
and another question, how can i use xc(with hex) to create 8-bit png?
I don't know. It does not seem to work if you use only black or white with hex. IM probably recognizes that you only have black or white and makes a 1-bit image so as to be as small as possible. Does it come out larger than 1-bit if you some other color? Why does it matter if you get a 1-bit black image or 8-bits or 16-bits? Once you process that image with some other to make another image, the result will likely be the bit-resolution of your IM compilation.
So if I do:
convert -size 100x100 xc:'#45678900' PNG32:result6.png
identify -verbose result6.png
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
I get 8-bit channels with 1-bit alpha
It is just that you are using black for your hex color and IM knows that and does not need to make 8-bits to create such an image. It can do so with 1-bit just as well and save space.
see
http://www.imagemagick.org/Usage/formats/
but also my bug report
viewtopic.php?f=3&t=14498