473,382 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

JPG Image Load,Resize,Save with 100% Python?

Hello,

I am looking for a 100% python lib/script which can load a jpg image,
detect its size, resize and save it as new file.

I have found some tools (like PIL), but all of them use ImageMagic or
external dlls, which can not be used on my web server.

I hope you can help me.

Ingo

Jul 18 '05 #1
7 4320
Ingo Linkweiler <i.**********@web.de> wrote in message news:<c0*************@news.t-online.com>...
Hello,

I am looking for a 100% python lib/script which can load a jpg image,
detect its size, resize and save it as new file.

I have found some tools (like PIL), but all of them use ImageMagic or
external dlls, which can not be used on my web server.

I hope you can help me.

Ingo


There is nothing like this.

Because this is a task that can't be done in Python well.
You must expect it to be around 140 times (thats 14000%) slower then a
C library thats why nobody wants to do it.
Jul 18 '05 #2
> There is nothing like this.

Because this is a task that can't be done in Python well.
You must expect it to be around 140 times (thats 14000%) slower then a
C library thats why nobody wants to do it.


140 seems pretty extreme. Most tests I've run put numeric calculations
at around 10-20 times slower, not 140.

A better answer as to why there isn't a pure python module is because
there already exists numerous C JPEG libraries, which are much easier to
wrap with SWIG, than to rewrite completely in Python.

- Josiah
Jul 18 '05 #3
"Ingo Linkweiler" <i.**********@web.de> a écrit dans le message de
news:c0*************@news.t-online.com...
Hello,

I am looking for a 100% python lib/script which can load a jpg image,
detect its size, resize and save it as new file.

I have found some tools (like PIL), but all of them use ImageMagic or
external dlls, which can not be used on my web server.

I hope you can help me.

Ingo


Have a look at how Zope detects JPGs and gets their size, in the
..../lib/python/OFS/File.py (Image class) in a 100% core Python way.
Unfortunately resizing a JPEG in pure python is something that nobody does
because resizing a bitmap image (in whatever format) in pure Python would be
very slow.

HTH

--
Gilles
Jul 18 '05 #4
Josiah Carlson <jc******@nospam.uci.edu> wrote in message news:<c0**********@news.service.uci.edu>...
There is nothing like this.

Because this is a task that can't be done in Python well.
You must expect it to be around 140 times (thats 14000%) slower then a
C library thats why nobody wants to do it.


140 seems pretty extreme. Most tests I've run put numeric calculations
at around 10-20 times slower, not 140.


A Jpeg libaary with a good optimization does only integer algorithm
and this is different from FP operations which are already slow on
Intel CPU's.

But i find find it strange that numerics (without using special
extensions) should only be 10-20 times slower then C. This is not what
you find in other benchmarks.

For example in the great language shootout
"http://www.bagley.org/~doug/shootout/bench/sieve/"
you find that the "Sieve of Eratosthenes" as an integer algorithm 207
times slower then c. I think the algorithms are compareable in their
use of instructions.
Jul 18 '05 #5
>>140 seems pretty extreme. Most tests I've run put numeric calculations
at around 10-20 times slower, not 140.
A Jpeg libaary with a good optimization does only integer algorithm
and this is different from FP operations which are already slow on
Intel CPU's.

But i find find it strange that numerics (without using special
extensions) should only be 10-20 times slower then C. This is not what
you find in other benchmarks.


That 10-20 times slower metric was doing numerical integration in pure
Python and ANSI standard C, originally run using Python version 2.0 (2.3
is roughly 20% faster than 2.0). Certainly it was using floating point
math, but that suggests that there is less of a difference using Python
and FP math than when using integer math.

For example in the great language shootout
"http://www.bagley.org/~doug/shootout/bench/sieve/"
you find that the "Sieve of Eratosthenes" as an integer algorithm 207
times slower then c. I think the algorithms are compareable in their
use of instructions.


I just sent the author an update to his version in Python that reduces
runtime from ~47 seconds to ~37 seconds, putting it at only ~160 times
slower.

Unfortunately the test still isn't fair. The Python version ends up
creating and destroying lists (arrays) of 8193 elements, and over the
running of the algorithm, will need to allocate and free 8 megs. It
turns out that creating and destroying is faster in Python, but that
really just means that Python should probably have a better sequence
initialization function.
- Josiah

Jul 18 '05 #6
On Sun, 8 Feb 2004 5:25:47 -0800, Ingo Linkweiler wrote
(in message <c0*************@news.t-online.com>):
I am looking for a 100% python lib/script which can load a jpg image,
detect its size, resize and save it as new file.


Note that decoding, resizing and recompressing a JPEG hurts the
quality. See:
http://www.faqs.org/faqs/jpeg-faq/

--
Derek Ledbetter
de****@serve.com

Heavy boots of lead
fills his victims full of dread
Running as fast as they can
Iron Man lives again!
Jul 18 '05 #7
> There is nothing like this.

Because this is a task that can't be done in Python well.
You must expect it to be around 140 times (thats 14000%) slower then a
C library thats why nobody wants to do it.


thanks, than i will use PIL or wxPython. I have tested both with good
results.

Ingo

Jul 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: querypk | last post by:
Hi I would like to know how to resize an Image without using python Imaging library.
8
by: Chris Dewin | last post by:
Hi. I run a website for my band, and the other guys want an image gallery. I'm thinking it would be nice and easy, if we could just upload a jpg into a dir called "gallery/". When the client...
0
by: Duncan Welch | last post by:
I've got users uploading a file, which I then want resize, make a thumbnail out of, then delete. The image and thumbnail are working fine, but when I try to delete the image, I get an error: "The...
10
by: David W. Simmonds | last post by:
I have a DataList control that has an Image control in the ItemTemplate. I would like to resize the image that goes into that control. I have a series of jpg files that are full size, full...
3
by: DichkoSoft | last post by:
Dear All I don't know haw i resize inage in VB.NET I want load image with size 800x600 then rezize it to 80x60 pixels and save to a file. -- DichkoSoft
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
3
by: Noorain | last post by:
Sir i want to resize image. Following script working in my local server. But This coding doesn't work in php 2.6.0. please help me <form action="<?php echo $_server; ?>" method="post"...
22
by: simon2x1 | last post by:
i have an image which width is 213 and height is 200 when i echo the image and i resize it echo "<img src='company/$present' width='70' height='68'/>"; the image was not as clear as when it was...
14
anfetienne
by: anfetienne | last post by:
hi.....i have this script (below #1) that is linked to another php file SimpleImage.php (#2) im trying to get it to work on my uploaded images but it keeps coming up errors.....i haven't altered...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.