473,748 Members | 6,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

faster rotate and resize of images

is it just me or does anybody else find the Image.RotateFli p 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(sourceIm age, newWidth, newHeight)
newImage.save(n ewFileString)

Anyone knows of any faster methods?
Nov 23 '05 #1
7 3124
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**@discussio ns.microsoft.co m> schreef in bericht
news:23******** *************** ***********@mic rosoft.com...
is it just me or does anybody else find the Image.RotateFli p 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(sourceIm age, newWidth, newHeight)
newImage.save(n ewFileString)

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**@discussio ns.microsoft.co m> schreef in bericht
news:23******** *************** ***********@mic rosoft.com...
is it just me or does anybody else find the Image.RotateFli p 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(sourceIm age, newWidth, newHeight)
newImage.save(n ewFileString)

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**@discussio ns.microsoft.co m> schreef in bericht
news:BC******** *************** ***********@mic rosoft.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**@discussio ns.microsoft.co m> schreef in bericht
news:23******** *************** ***********@mic rosoft.com...
is it just me or does anybody else find the Image.RotateFli p 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(sourceIm age, newWidth, newHeight)
newImage.save(n ewFileString)

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**@discussio ns.microsoft.co m> schreef in bericht
news:BC******** *************** ***********@mic rosoft.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**@discussio ns.microsoft.co m> schreef in bericht
news:23******** *************** ***********@mic rosoft.com...
> is it just me or does anybody else find the Image.RotateFli p 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(sourceIm age, newWidth, newHeight)
> newImage.save(n ewFileString)
>
> 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(ImageStr ing)

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

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

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

If ext = ".bmp" Then
destImg.Save(de stFileName,Syst em.Drawing.Imag ing.ImageFormat .Bmp)

ElseIf ext = ".jpg" Then
destImg.Save(de stFileName,Syst em.Drawing.Imag ing.ImageFormat .jpeg)

End If
sourceImg.Dispo se()
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(Bitm ap.FromFile(fil es(i)), Bitmap)
destImg = New Bitmap(400, 400)
destImg .SetResolution( imgOrg.Horizont alResolution,
imgOrg.Vertical Resolution)
g = Graphics.FromIm age(destImg )
g.Interpolation Mode = Drawing2D.Inter polationMode.Hi ghQualityBicubi c
g.DrawImage(sou rceImg , New Rectangle(0, 0, 400, 400), 0, 0, sourceImg
..Width, sourceImg .Height, GraphicsUnit.Pi xel)
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**@discussio ns.microsoft.co m> schreef in bericht
news:0F******** *************** ***********@mic rosoft.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(ImageStr ing)

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

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

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

If ext = ".bmp" Then
destImg.Save(de stFileName,Syst em.Drawing.Imag ing.ImageFormat .Bmp)

ElseIf ext = ".jpg" Then
destImg.Save(de stFileName,Syst em.Drawing.Imag ing.ImageFormat .jpeg)

End If
sourceImg.Dispo se()
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(Bitm ap.FromFile(fil es(i)), Bitmap)
destImg = New Bitmap(400, 400)
destImg .SetResolution( imgOrg.Horizont alResolution,
imgOrg.Vertical Resolution)
g = Graphics.FromIm age(destImg )
g.Interpolation Mode = Drawing2D.Inter polationMode.Hi ghQualityBicubi c
g.DrawImage(sou rceImg , New Rectangle(0, 0, 400, 400), 0, 0, sourceImg
..Width, sourceImg .Height, GraphicsUnit.Pi xel)
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**@discussio ns.microsoft.co m> schreef in bericht
news:0F******** *************** ***********@mic rosoft.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(ImageStr ing)

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

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

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

If ext = ".bmp" Then
destImg.Save(de stFileName,Syst em.Drawing.Imag ing.ImageFormat .Bmp)

ElseIf ext = ".jpg" Then
destImg.Save(de stFileName,Syst em.Drawing.Imag ing.ImageFormat .jpeg)

End If
sourceImg.Dispo se()
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
27859
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 create a 'standard' size for display on a page)? Thanks your help would be much appreciated. JEB
4
18606
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
1734
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 image is uploaded and store it in the database. My client now thinks the images are too small and needs to be resized. I can change the resize height/weight (settings in web.config), but since the resize happens only once on upload - all the...
0
282
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 or max. 400 pixel width or max. 100 Kb. The image is not uploaded. How can I do this? Additionally, I also want to resize the images to a valid size when they are to big than the specified size (max. 400 pixel in height or
11
2353
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 calulate dimension for 7 jpeg images. I have a 700mhz processor (Pentium III, remember those??)! with almost a gb of memory. Is that the way GD is??? Here is a snippet of the dode I use: I pass
6
2716
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 information for an image residing on the local drive. I'm attempting to reduce the upload time for large pictures. Any thoughts? :) EXAMPLE Function call:
2
1093
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. I'm guessing it would pull from an XML file or similar. Hopefully, the user could click it and it go to a detail page and pass along the Id of the employee clicked on.
1
7261
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 resize/adjust the height/width of the images automatically. Here is the code for the looped slider: <div id="loopedSlider" class="feature"> <div class="container"> <div class="slides">
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6796
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.