PNG to BMP3 using mogrify

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
pendel
Posts: 3
Joined: 2013-08-08T02:41:02-07:00
Authentication code: 6789

PNG to BMP3 using mogrify

Post by pendel »

I've got a series of PNG images that I need to convert to BMP version 3. I have a windows app that won't tolerate BMP in version 4.

I've read the BMP info and I can successfully use convert to achieve the desired result, but I can't seem to find a way to do the same using mogrify. I've got hundreds of images to convert, so mogrify batch conversion would be highly desirable....

This works:

Code: Select all

convert test1.png BMP3:test.bmp
This doesn't:

Code: Select all

mogrify -format BMP3 test*.png
(It just produces files with a BMP3 suffix, like test1.BMP3).

It seems that I need to use

Code: Select all

mogrify -format bmp test*.png
but with some other switch to force BMP3 output?

Any help greatly appreciated...
pendel
Posts: 3
Joined: 2013-08-08T02:41:02-07:00
Authentication code: 6789

Re: PNG to BMP3 using mogrify

Post by pendel »

It seems the test1.BMP3 file that is produced is in a valid BMP3 format, so it's just the file extension that is invalid.

So, I can do my batch conversion, and then batch rename by doing this:

Code: Select all

mogrify -format BMP3 test*.png
mogrify -format bmp test*.BMP3
But that's going to take twice as long... Is there a way to do it with a single command/pass?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PNG to BMP3 using mogrify

Post by snibgo »

If I understand correctly, your second command uses mogrify just to rename the files, from *.BMP3 to *.bmp.

Your shell will have a command to do this much faster, eg in Windows:

Code: Select all

ren *.BMP3 *.bmp
snibgo's IM pages: im.snibgo.com
pendel
Posts: 3
Joined: 2013-08-08T02:41:02-07:00
Authentication code: 6789

Re: PNG to BMP3 using mogrify

Post by pendel »

Thanks snibgo,

Yes, I was aware of the ren command, and have used it to solve my problem. I was showing the second mogrify command to emphasize the fact that the -format switch is applying the right format in each command.

There is a difference between file format and file extension... That's why the convert command lets you use BMP3:test1.bmp to define the format AND the file extension.

It seems the mogrify command lacks the ability to define the format AND the extension - or is there a switch I don't know about?

I tried:

Code: Select all

mogrify -format BMP3:bmp test*.png
but I just get an invalid 0KB file with a BMP3 extension, without any notification from IM that the format string, and resulting file, are invalid.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PNG to BMP3 using mogrify

Post by snibgo »

As far as I know, mogrify can't specify the file extension independently of the format. But I don't use mogrify (or BMP) much.

For mogrify options, see http://www.imagemagick.org/script/mogrify.php
snibgo's IM pages: im.snibgo.com
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG to BMP3 using mogrify

Post by glennrp »

I've patched the SVN repository with a new "-define bmp:format=bmp2|bmp3|bmp4" option, which will appear in
ImageMagick-6.8.6-9. This can be used with mogrify, where the "bmpN:" prefix is not available for controlling
the output format without also changing the filename extension.

In your case, you'd use

Code: Select all

mogrify -format bmp -define bmp:format=bmp3 test*.png
to create a bunch of test*.bmp files in BMP3 format.
Post Reply