473,418 Members | 2,056 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,418 software developers and data experts.

faster rotate and resize of images

is it just me or does anybody else find the Image.RotateFlip method kind of
slow? (I'm comparing to commercial softwares). Same for resizing. I'm using

sourceImage = system.drawing.bitmap.fromFile(filestring)
newImage = new bitmpa(sourceImage, newWidth, newHeight)
newImage.save(newFileString)

Anyone knows of any faster methods?
Nov 23 '05 #1
7 3102
Hi,

what dou you call slow? Because I also resize images in my app and you don't
even see or notice that it happens

you can find my code at:

http://www.vb-tips.com/default.aspx?...5-3479119c0d1c

hth Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"chad" <ch**@discussions.microsoft.com> schreef in bericht
news:23**********************************@microsof t.com...
is it just me or does anybody else find the Image.RotateFlip method kind of slow? (I'm comparing to commercial softwares). Same for resizing. I'm using
sourceImage = system.drawing.bitmap.fromFile(filestring)
newImage = new bitmpa(sourceImage, newWidth, newHeight)
newImage.save(newFileString)

Anyone knows of any faster methods?

Nov 23 '05 #2
thanks Peter. I just went thru your code. It's almost the same as what I have.
what dou you call slow? Because I also resize images in my app and you don't
even see or notice that it happens
Well, for single images, you can't feel it, but in a batch job, like
100 images, the 'slowness' can be felt.

many thanks btw :-)


"Peter Proost" wrote:
Hi,

what dou you call slow? Because I also resize images in my app and you don't
even see or notice that it happens

you can find my code at:

http://www.vb-tips.com/default.aspx?...5-3479119c0d1c

hth Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"chad" <ch**@discussions.microsoft.com> schreef in bericht
news:23**********************************@microsof t.com...
is it just me or does anybody else find the Image.RotateFlip method kind

of
slow? (I'm comparing to commercial softwares). Same for resizing. I'm

using

sourceImage = system.drawing.bitmap.fromFile(filestring)
newImage = new bitmpa(sourceImage, newWidth, newHeight)
newImage.save(newFileString)

Anyone knows of any faster methods?


Nov 23 '05 #3
Hi Chad, could you post your code? It's always good to see how someone else
does something.
And how long does it take for you to resize 100 images? With a program I've
written about a year ago that creates thumbnails and resizes the original
images it takes 47sec to resize 504 images and create 504 thumbnails which
in my opinion is acceptable. But you don't need to forget that gdi+ just
isn't super fast. :-)

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"chad" <ch**@discussions.microsoft.com> schreef in bericht
news:BC**********************************@microsof t.com...
thanks Peter. I just went thru your code. It's almost the same as what I have.
what dou you call slow? Because I also resize images in my app and you don't even see or notice that it happens


Well, for single images, you can't feel it, but in a batch job, like
100 images, the 'slowness' can be felt.

many thanks btw :-)


"Peter Proost" wrote:
Hi,

what dou you call slow? Because I also resize images in my app and you don't even see or notice that it happens

you can find my code at:

http://www.vb-tips.com/default.aspx?...5-3479119c0d1c
hth Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"chad" <ch**@discussions.microsoft.com> schreef in bericht
news:23**********************************@microsof t.com...
is it just me or does anybody else find the Image.RotateFlip method
kind of
slow? (I'm comparing to commercial softwares). Same for resizing. I'm

using

sourceImage = system.drawing.bitmap.fromFile(filestring)
newImage = new bitmpa(sourceImage, newWidth, newHeight)
newImage.save(newFileString)

Anyone knows of any faster methods?


Nov 23 '05 #4
I had read somewhere that VB.Net 2005 would include a faster GDI+...is this
correct?
--
Dennis in Houston
"Peter Proost" wrote:
Hi Chad, could you post your code? It's always good to see how someone else
does something.
And how long does it take for you to resize 100 images? With a program I've
written about a year ago that creates thumbnails and resizes the original
images it takes 47sec to resize 504 images and create 504 thumbnails which
in my opinion is acceptable. But you don't need to forget that gdi+ just
isn't super fast. :-)

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"chad" <ch**@discussions.microsoft.com> schreef in bericht
news:BC**********************************@microsof t.com...
thanks Peter. I just went thru your code. It's almost the same as what I

have.
what dou you call slow? Because I also resize images in my app and you don't even see or notice that it happens


Well, for single images, you can't feel it, but in a batch job, like
100 images, the 'slowness' can be felt.

many thanks btw :-)


"Peter Proost" wrote:
Hi,

what dou you call slow? Because I also resize images in my app and you don't even see or notice that it happens

you can find my code at:

http://www.vb-tips.com/default.aspx?...5-3479119c0d1c
hth Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"chad" <ch**@discussions.microsoft.com> schreef in bericht
news:23**********************************@microsof t.com...
> is it just me or does anybody else find the Image.RotateFlip method kind of
> slow? (I'm comparing to commercial softwares). Same for resizing. I'm
using
>
> sourceImage = system.drawing.bitmap.fromFile(filestring)
> newImage = new bitmpa(sourceImage, newWidth, newHeight)
> newImage.save(newFileString)
>
> Anyone knows of any faster methods?


Nov 23 '05 #5
hi Peter, here's the code. Btw, it takes about 60sec to do 100images. But
then again, it really depends on the hdd. RAID will perform better, though.

'************************************************* ******

For i As Integer = 0 To UBound(ImageString)

Dim sourceImg As System.Drawing.Image
Dim destImg As System.Drawing.Bitmap

sourceImg = System.Drawing.Bitmap.FromFile(ImageString(i)) 'image
destImg = New Bitmap(sourceImg, newWidth, newHeight) 'constructor

destFileName = destFolder & "\" & Path.GetFileName(ImageString(i))

If ext = ".bmp" Then
destImg.Save(destFileName,System.Drawing.Imaging.I mageFormat.Bmp)

ElseIf ext = ".jpg" Then
destImg.Save(destFileName,System.Drawing.Imaging.I mageFormat.jpeg)

End If
sourceImg.Dispose()
destImg.Dispose()

sourceImg = Nothing
destImg = Nothing

Next
'************************************************* ******

"Peter Proost" wrote:
Hi Chad, could you post your code? It's always good to see how someone else
does something.
And how long does it take for you to resize 100 images? With a program I've
written about a year ago that creates thumbnails and resizes the original
images it takes 47sec to resize 504 images and create 504 thumbnails which
in my opinion is acceptable. But you don't need to forget that gdi+ just
isn't super fast. :-)

Greetz Peter

Nov 23 '05 #6
Hi Chad, I woul get
Dim sourceImg As System.Drawing.Image
Dim destImg As System.Drawing.Bitmap
out of the for loop

And maybe you can try this code to resize the images but I don't think it
will be much faster, the example is with fixed values which ofcourse isn't
the correct way to work.

sourceImg = DirectCast(Bitmap.FromFile(files(i)), Bitmap)
destImg = New Bitmap(400, 400)
destImg .SetResolution(imgOrg.HorizontalResolution,
imgOrg.VerticalResolution)
g = Graphics.FromImage(destImg )
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(sourceImg , New Rectangle(0, 0, 400, 400), 0, 0, sourceImg
..Width, sourceImg .Height, GraphicsUnit.Pixel)
g.Dispose()
imgOrg.Dispose()

And as you said yourself it also has got a lot to do with your computer
speed because I tested my method and your method on my pc And they both took
about 17 seconds (16.9 and 17.7 seconds) to resize 100 images

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"chad" <ch**@discussions.microsoft.com> schreef in bericht
news:0F**********************************@microsof t.com... hi Peter, here's the code. Btw, it takes about 60sec to do 100images. But
then again, it really depends on the hdd. RAID will perform better, though.
'************************************************* ******

For i As Integer = 0 To UBound(ImageString)

Dim sourceImg As System.Drawing.Image
Dim destImg As System.Drawing.Bitmap

sourceImg = System.Drawing.Bitmap.FromFile(ImageString(i)) 'image
destImg = New Bitmap(sourceImg, newWidth, newHeight) 'constructor

destFileName = destFolder & "\" & Path.GetFileName(ImageString(i))

If ext = ".bmp" Then
destImg.Save(destFileName,System.Drawing.Imaging.I mageFormat.Bmp)

ElseIf ext = ".jpg" Then
destImg.Save(destFileName,System.Drawing.Imaging.I mageFormat.jpeg)

End If
sourceImg.Dispose()
destImg.Dispose()

sourceImg = Nothing
destImg = Nothing

Next
'************************************************* ******

"Peter Proost" wrote:
Hi Chad, could you post your code? It's always good to see how someone else does something.
And how long does it take for you to resize 100 images? With a program I've written about a year ago that creates thumbnails and resizes the original images it takes 47sec to resize 504 images and create 504 thumbnails which in my opinion is acceptable. But you don't need to forget that gdi+ just
isn't super fast. :-)

Greetz Peter

Nov 23 '05 #7
yup, I tried it and it's about the same timings. Guess it's the best GDI+ can
do :-)

Chad

"Peter Proost" wrote:
Hi Chad, I woul get
Dim sourceImg As System.Drawing.Image
Dim destImg As System.Drawing.Bitmap


out of the for loop

And maybe you can try this code to resize the images but I don't think it
will be much faster, the example is with fixed values which ofcourse isn't
the correct way to work.

sourceImg = DirectCast(Bitmap.FromFile(files(i)), Bitmap)
destImg = New Bitmap(400, 400)
destImg .SetResolution(imgOrg.HorizontalResolution,
imgOrg.VerticalResolution)
g = Graphics.FromImage(destImg )
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(sourceImg , New Rectangle(0, 0, 400, 400), 0, 0, sourceImg
..Width, sourceImg .Height, GraphicsUnit.Pixel)
g.Dispose()
imgOrg.Dispose()

And as you said yourself it also has got a lot to do with your computer
speed because I tested my method and your method on my pc And they both took
about 17 seconds (16.9 and 17.7 seconds) to resize 100 images

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"chad" <ch**@discussions.microsoft.com> schreef in bericht
news:0F**********************************@microsof t.com...
hi Peter, here's the code. Btw, it takes about 60sec to do 100images. But
then again, it really depends on the hdd. RAID will perform better,

though.

'************************************************* ******

For i As Integer = 0 To UBound(ImageString)

Dim sourceImg As System.Drawing.Image
Dim destImg As System.Drawing.Bitmap

sourceImg = System.Drawing.Bitmap.FromFile(ImageString(i)) 'image
destImg = New Bitmap(sourceImg, newWidth, newHeight) 'constructor

destFileName = destFolder & "\" & Path.GetFileName(ImageString(i))

If ext = ".bmp" Then
destImg.Save(destFileName,System.Drawing.Imaging.I mageFormat.Bmp)

ElseIf ext = ".jpg" Then
destImg.Save(destFileName,System.Drawing.Imaging.I mageFormat.jpeg)

End If
sourceImg.Dispose()
destImg.Dispose()

sourceImg = Nothing
destImg = Nothing

Next
'************************************************* ******

"Peter Proost" wrote:
Hi Chad, could you post your code? It's always good to see how someone else does something.
And how long does it take for you to resize 100 images? With a program I've written about a year ago that creates thumbnails and resizes the original images it takes 47sec to resize 504 images and create 504 thumbnails which in my opinion is acceptable. But you don't need to forget that gdi+ just
isn't super fast. :-)

Greetz Peter


Nov 23 '05 #8

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

Similar topics

3
by: LORD BROWN | last post by:
Was wondering if any one knew of any code, or could point me to a site that has an example of resizing images using JavaScript (have a site were many of the image are not the same size and want to...
4
by: SlasherStanley | last post by:
BlankHi How do you resize a jpg file. I want to open a file (c:\abc.jpg 800 x 600) and resize it as 120 x 100, I then want to save it as c:\abc_t.jpg. Thanks Slasher
2
by: J'son | last post by:
Guys, I have built an application for a client that allows people to list their products for sale along with a photo of the product. If the photo is too big, I currently resize it down when the...
0
by: IkBenHet | last post by:
Hello, I use this ASP.NET script to upload images to my website: Now, I want to limit the size (in width and height, but also in bytes). For example, if the image is max. 400 pixel in height...
11
by: eholz1 | last post by:
Hello PHP group, I am using some php code to check the size of images, and then resize or determine new dimension for the image. GD seems quite slow. It takes about 5 seconds (plus or minus) to...
6
by: snaeher | last post by:
Functions using file references to images on my local drive return the file not found warning. The functions work fine if the image has been uploaded to the server, but returns errors when calling...
2
by: Ronald S. Cook | last post by:
Hi, Is there a control (either built-in or 3rd party) that I can put on my web page that I can set up to "rotate" through, let's say, images of employees at our company... say 5 seconds each. ...
1
by: Chris Rock | last post by:
I have a "Looped Slider" that displays a series of images, but I've had to manually resize the images (using height/width tags), but I'm looking for some code that will take the width of the DIV, and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.