|
-
Aug 30th, 2007, 04:17 PM
#1
[2005] Image Manipulation
I usually write business apps, but I am working on an image editing utility for a friend of mine who is currently scanning a few thousand pictures into his PC.
I am not trying to reinvent the wheel as there are many really good image editing apps out there, so I am only trying to include functionality that pertains to what he needs it for.
So far it has been pretty simple, except for some roadblocks which I have so far overcome. The biggest issues I have faced are the fact that once you load an image in .NET to a bitmap or image object, that file is locked until you dispose of the image object. This makes it hard to do something like open an image, manipulate it, and save it back to the same file name. I have a decent work around for that though.
I am currently just sitting on one issue so I figure maybe someone has some insight on this:
My problem is one of the few manipulations I need to be able to do is rotate an image. Sure this is simple enough to do using the RotateFlip method of the image or bitmap class. The problem is when you save back to disk though.
If I load a jpeg file from disk, and save it back to disk, the file size remains exactly the same. However if I apply a rotation to the image, the size grows by several megs when I save it back. If I specify JPEG as the format for encoding, the size cuts down to about half the original size.
here is some code that illustrates the issue:
Code:
'ORIGINAL TESTING PIC IS 1.3MB
'OPEN AND SAVE WITH NO TRANSFORM
Using MyImage As Image = Image.FromFile("C:\somepic.jpg")
MyImage.Save(Application.StartupPath & "\testpic2.jpg", MyImage.RawFormat)
'SIZE OF THIS FILE IS 1.3MB
End Using
'SAVE USING SAME IMAGEFORMAT OF ORIGINAL IMAGE
Using MyImage As Image = Image.FromFile("C:\somepic.jpg")
MyImage.RotateFlip(RotateFlipType.Rotate90FlipNone)
MyImage.Save(Application.StartupPath & "\testpic2.jpg", MyImage.RawFormat)
'SIZE OF THIS FILE IS OVER 9MB
End Using
'SAVE USING JPEG
Using MyImage As Image = Image.FromFile("C:\somepic.jpg")
MyImage.RotateFlip(RotateFlipType.Rotate90FlipNone)
MyImage.Save(Application.StartupPath & "\testpic2.jpg", ImageFormat.Jpeg)
'SIZE OF THIS FILE IS 629KB
End Using
-
Aug 30th, 2007, 04:41 PM
#2
Fanatic Member
Re: [2005] Image Manipulation
I am just talking out my a** but could you copy the contents of the image file into binary, and then into a new Image object that would not be linked into that file. Close the file. Delete it. Then your new image as it.
-
Aug 30th, 2007, 04:51 PM
#3
Re: [2005] Image Manipulation
I am not sure how that would help with with the file size/encoding of the image??
-
Aug 30th, 2007, 05:06 PM
#4
Fanatic Member
Re: [2005] Image Manipulation
nm.. I thought you had that handled, but were just looking for a way to save your changes back to the same file name.
-
Aug 30th, 2007, 05:18 PM
#5
Re: [2005] Image Manipulation
-
Aug 30th, 2007, 05:30 PM
#6
Fanatic Member
Re: [2005] Image Manipulation
-
Aug 30th, 2007, 05:52 PM
#7
Re: [2005] Image Manipulation
 Originally Posted by BillBoeBaggins
Thanks I will check that out and see how it fairs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|