Cropping 16 bit .BMP files and maintaining pixel size
Cropping 16 bit .BMP files and maintaining pixel size
IUsing IM 7.0.4-6 Q16 on Windows platform.
I have a 16 bit BMP which is RGB 5:6:5 file and I want to crop an area from it, I use the command:
magick convert -crop 72x66+16+62 "GPS ICONS Total FINAL_42.bmp" cam1.bmp
which produces a file cam1.bmp file with the correct image in it, however it now is saved as a 24bit .BMP file ie rgb 8:8:8. Image size is a factor for me so i want to maintain the image with only 2 bytes per pixel rather than 3, is it possible to do this and if so how?
I have a 16 bit BMP which is RGB 5:6:5 file and I want to crop an area from it, I use the command:
magick convert -crop 72x66+16+62 "GPS ICONS Total FINAL_42.bmp" cam1.bmp
which produces a file cam1.bmp file with the correct image in it, however it now is saved as a 24bit .BMP file ie rgb 8:8:8. Image size is a factor for me so i want to maintain the image with only 2 bytes per pixel rather than 3, is it possible to do this and if so how?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Cropping 16 bit .BMP files and maintaining pixel size
I don't think IM can save as BMP 5:6:5.
snibgo's IM pages: im.snibgo.com
Re: Cropping 16 bit .BMP files and maintaining pixel size
That would be a real shame, It seems it can do everything else!!
It can read the BMP file in 5:6:5!!
It can read the BMP file in 5:6:5!!
Re: Cropping 16 bit .BMP files and maintaining pixel size
If it cant, is there an official way to suggest an enhancement to IM?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Cropping 16 bit .BMP files and maintaining pixel size
Post an entry in the Developers forum: viewforum.php?f=2
You can include a link to this thread: viewtopic.php?f=1&t=33334&sid=6ceff1fda ... 1a38826f62
It would probably help the developers if you include a link to a sample 5:6:5 file.
You can include a link to this thread: viewtopic.php?f=1&t=33334&sid=6ceff1fda ... 1a38826f62
It would probably help the developers if you include a link to a sample 5:6:5 file.
snibgo's IM pages: im.snibgo.com
Re: Cropping 16 bit .BMP files and maintaining pixel size
There is already an option to write RGB565:
It seems to work okay with the default BMP version, but I think there's a bug that prevents it from working properly with BMPv3 ("BMP3:" or "-define bmp:format=bmp3").
Code: Select all
-define bmp:subtype=RGB565
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Cropping 16 bit .BMP files and maintaining pixel size
Well-spotted, Jason.
@Fred: that define isn't in http://www.imagemagick.org/script/comma ... ptions.php . Can it be added?
@Fred: that define isn't in http://www.imagemagick.org/script/comma ... ptions.php . Can it be added?
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Cropping 16 bit .BMP files and maintaining pixel size
Yes, I already noticed that and have to ask Dirk about the BMP3 issue before adding the define to the docs. Waiting on an answer.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Cropping 16 bit .BMP files and maintaining pixel size
I have updated the docs. Note that this -define is only for BMP (BMP4). It is the only BMP format that supports arguments in the header for such options, according to Dirk.
It might take a day for them to pull over.
It might take a day for them to pull over.
Re: Cropping 16 bit .BMP files and maintaining pixel size
so it was there just not documented!!
I have tried this and it works great.
-define bmp:subtype=RGB565
Not satisfied with that I tried:
-define bmp:subtype=ARGB1555
And that did not seem to work, it produced a file with 24 bits per pixel, I thought that ARGB1555 should fit in 16 bits?
I have tried this and it works great.
-define bmp:subtype=RGB565
Not satisfied with that I tried:
-define bmp:subtype=ARGB1555
And that did not seem to work, it produced a file with 24 bits per pixel, I thought that ARGB1555 should fit in 16 bits?
Re: Cropping 16 bit .BMP files and maintaining pixel size
I haven't looked at this closely, but I confirm that the ARGB1555 option seems to write a 24bpp image if the image has no transparency (and more than 256 colors). If the image has transparency, then it writes a 16bpp image as expected. Looks like a bug to me.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Cropping 16 bit .BMP files and maintaining pixel size
What happens if you add -type palettealpha to your command.-define bmp:subtype=ARGB1555
And that did not seem to work, it produced a file with 24 bits per pixel, I thought that ARGB1555 should fit in 16 bits?
Top
Re: Cropping 16 bit .BMP files and maintaining pixel size
With -type palettealpha it produces an image with 32 bits per pixel, although it does have an alpha channel now.