• Welcome to Vampyre Imaging Library Forum. Please login or sign up.

Resize image to a size limit

Started by yapt, 1 February 2009, 15:00:27

Previous topic - Next topic



I am new to Vampyre Imaging library, I only want use imaging library to save an image to a sqlite database.  Then sqlite has a maximum size for the database image column.

I would like to know if I have any function to reduce (maintaining aspect ratio) the image memory size to any value I can specify.  I have read Resize and ResizeImage functions.  But both of them need an aspect limits (width or height).  But I would like to reduce any image to a 1Mb (ie) memory size.

Any clue about this ?


Well, I found this VB code that should do what you want to do: calculate
image dimensions given the max space they can occupy.
In what data format you want to save your images?
You would need to change first line to something like this (image.Width * image.Height * BytesPerPixel). 

shrinkFactor = MaxFieldLength / (image.Width * image.Height) 
outImageWidth = CInt(Math.Sqrt(shrinkFactor) * image.Width) 
outImageHeight = CInt(Math.Sqrt(shrinkFactor) * image.Height) 


Sorry my delay Galfar....

The format to save my images maybe jpeg, but at last I would like to lookup a way to save the images on the original format (I am saving all of them on SQLite fields).

I will try this code in a few days (perhaps the weekend).

Thanks a lot for your answer and sorry my delay again...


Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.


Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk