Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 30th, 2006, 1:56 PM   #1
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Smile Increase Image

What is the best way to double the size of an image and still have an acceptable quality?

I have a JPEG image format in mind.
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote
Old Apr 30th, 2006, 2:29 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,086
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
In pygame you can do it like so:

import pygame

image = pygame.image.load("my_image.jpeg")

size = image.get_size()

image = pygame.transform.scale(image, (size[0]*2, size[1]*2))

pygame.image.save("my_new_image.bmp", image)

The problem with that is it can only be saved in bitmap.

I used PIL to do this, but don't feel like digging through old code to get it out. Sorry. If you search for the "Python Image Library Documentation", they already have example code for how to do it.

By the way, I haven't tested the pygame code. But it'll be roughly that if not exactly.
Sane is offline   Reply With Quote
Old Apr 30th, 2006, 2:53 PM   #3
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Sane,

that works! The arguments in save() have to be reversed.
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:06 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC