Page 1 of 1

bmp file manipulation

Posted: 2008-06-10T11:31:48-07:00
by rjdempsey
I've developed a site which allows clients to upload images. The images are resized, thumbnails are created and cached, etc. Standard stuff. My client contacted me about some bugs he was finding on the site. I realized it was because some users were trying to use .BMP images instead of jpegs.

My suggestion was to simply abstain from using .BMP and use only jpegs. But I'm also looking into trying to support .BMP as well.

I'm new with ImagaMagick. Can anyone tell me if this is doable? I need automatically generated medium sized and thumbnails images from a .BMP file. The other solution if possible is to convert the .BMP to .JPG on the fly. Would that make sense to do?

Thanks,

Ryan

Re: bmp file manipulation

Posted: 2008-06-10T11:37:06-07:00
by Bonzo
If you read a bmp in you should be able to save as a bmp; you can also read a bmp and save as a jpg.

We need more information of how you are using the IM code.

EDIT:

I use php and on one of my sites I get the image extension and amend it to the the new image name to keep the format.

Re: bmp file manipulation

Posted: 2008-06-10T11:40:28-07:00
by rjdempsey
I'm actually not using ImageMagick yet. I'm using GD. I'm on these boards to inquire if IM would more easily facilitate this than GD as my client did a google search and felt magickwand might be something that could help.

Re: bmp file manipulation

Posted: 2008-06-10T11:47:24-07:00
by Bonzo
I think image magick is a lot simpler - I use the comand line with php ( see my sig ). You do not need to worry about things like imagecreatefrompng etc. as the same line of code in your case will work for over 100 different image formats.

Re: bmp file manipulation

Posted: 2008-06-10T11:56:28-07:00
by rjdempsey
Here are more specifics:

I'm actually using the Drupal CMS, with an Imagefield/ImageCache module. It simply allows users to upload an image and thumbnails are automatically generated. The underlying code uses GD. So I'm not really looking for an easier way, because using a cms is already easy as pie. :)

I am PHP coder though, and am fine with making my own modules if it better better achieves my goals.

I'm just looking for advice at the moment. Would it make sense for me to rework my site to allow .BMP's. Is it very easy to do this with IM? I need to be convinced that it is worth doing before I look into how to do it.

Re: bmp file manipulation

Posted: 2008-06-10T12:09:09-07:00
by Bonzo
Drupal have a crappy forum - I can not search it without loging in :(

This piece of code will resize whatever format of image is given to it and out put two other images as a jpg. You can use variables in the code.

Code: Select all

<?php
$image = "flowers.jpg";
exec("convert $image ( +clone -resize \"600x600\" -write first_save.jpg +delete ) -resize \"100x100\" thumbnail.jpg ");
?> 
What I did on a site was read the image name - get the extension - read the image into the code above and use the extension on the save names.

On GD you have to first decide on wether to use imagecreatefrompng etc. work out the aspect ratio ( IM keeps the aspect ratio unless told otherwise ) do some calculations etc. etc.

Here is an old upload example on my site: http://www.rubblewebs.co.uk./imagemagic ... /thumb.php