Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
paulm  
#1 Posted : Friday, December 3, 2004 3:45:00 AM(UTC)
paulm

Rank: Member

Groups: Member
Joined: 12/3/2004(UTC)
Posts: 3

I am using GM 2.0 to resize a set of JPG images. A number of the images, after resizing, are significantly larger than the others. For example, the original file sizes range from 1.5-4 MB. After resizing, they are anywhere usually 5/6K, but a bunch of them are almost 600K. I've tried adjusting the JpegQuality, and the InterpolationMode parameter of the Resize method, but it hasn't made much of a difference.

It appears to be happening with images that have a lot of solid colors. In the past, I've just use PNG for these types of images. However, in this case, I have to use JPEG. Does anyone have any suggestions to get the file size down to something reasonable?

Thanks,

-Paul

Andrew  
#2 Posted : Friday, December 3, 2004 2:57:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
Could you post a code snippet you use to save image to JPEG?
paulm  
#3 Posted : Sunday, December 5, 2004 11:16:00 PM(UTC)
paulm

Rank: Member

Groups: Member
Joined: 12/3/2004(UTC)
Posts: 3

Nothing fancy:

Code:
loPict.LoadFromFile("C:\SampleFile.jpg")
loPict.Transforms.Resize(65, -1)
loPict.SaveToFile("C:\NewFile.jpg")

I've also tried setting the JpegQuality without much luck.

I don't think this is an issue with GM - I think this is a Jpeg encoding issue (since I come out with similar file sizes if I use something like Photoshop). What I'm really looking for is ideas on how to get the filesize down to something reasonable while still using Jpeg encoding.

Thanks,

-Paul

Edited by user Monday, December 24, 2007 4:25:31 PM(UTC)  | Reason: Not specified

Andrew  
#4 Posted : Monday, December 6, 2004 12:09:00 AM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
When you specifying an optional encoder option, there is a small detail should be kept in mind: output file format should be specified explicitly. Otherwise default encoder options are used (including JpegQuality).

So try to use the following code:

Code:
loPict.LoadFromFile("C:\SampleFile.jpg")
loPict.Transforms.Resize(65, -1)
loPict.FormatAutoSelect = False
loPict.Formats.SelectCurrent("JPEG")
loPict.Formats.JpegQuality = 50
loPict.SaveToFile("C:\NewFile.jpg") 

Try to play with JpegQuality to find an acceptable size/quality ratio.

Hope this helps.

Edited by user Monday, December 24, 2007 4:25:40 PM(UTC)  | Reason: Not specified

paulm  
#5 Posted : Tuesday, December 7, 2004 1:44:00 AM(UTC)
paulm

Rank: Member

Groups: Member
Joined: 12/3/2004(UTC)
Posts: 3

It looks like reducing the color depth fixed the file size issue. Now I've got a new one. I've uploaded a set of resized images up to our website, and none of them are being displayed when I reference them. If I go back to the original image, resize it using Photoshop, then upload it back to the same location, the image gets displayed correctly.

At first, I thought it might be something with the way our site was configured (eg. it wasn't finding the image file correctly), so I tried the same thing on another site of mine using one image created using GM, the other using Photoshop. I could get the Photoshop image to display, but not the GM image. This test image did NOT require me to adjust the color depth (I used the coded posted previously to resize the image).

I can open the GM image up in my normal desktop apps. just fine. What else do I need to do with these JPG files to make them work on the web?

Thanks,

Andrew  
#6 Posted : Monday, January 3, 2005 4:00:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
Hello Paul,

Please excuse me for a delay.

I guess the problem is that you actually save into some other file format (e.g. TIFF). Could you submit case] with the following info:

  1. The original file.

  2. Full piece of code you use.

  3. The result file.

Edited by user Friday, May 23, 2008 3:45:20 PM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.