473,748 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GDI+ Error - problem with JPEG compression in Multi-page tiffs

I have multi-page tiff files. I need to extract individual frames from the
multi-page tiffs and save them as single-page tiffs. 95% of the time I
receive multi-page tiffs containing 1 or more black and white CCITT4
compressed files (frames) inside the tiff. Every now and then I receive a
mixture of black and white CCITT4 and JPEG compressed files, and sometimes
just multi-page tiffs with JPEG only. The code runs great when dealing with
the CCITT4 compressed files but fails every time it encounters a JPEG
compressed file (frame). I am using GDI+ and the System.Drawing and
System.Drawing. Imaging namespaces. The only bit of info I’ve found regarding
this problem was a single sentence stating ‘some methods in GDI+ don’t work
on JPEG and GIF files.’ Not very helpful. Here is the code.

The method ProcessDocument receives a string array containing the path to
the multi-page tiffs on the network.

Any leads would be greatly appreciated! I am lost...

private void ProcessDocument (string documentNumber, string[] pageFiles)
{
forUpload = true;
ArrayList images = null;
try
{
int pageIndex = -1;
images = new ArrayList();
foreach (string imageFilePath in pageFiles)
{
filePath = imageFilePath;
Bitmap image = null;
Guid g;
FrameDimension imgFrameDim;
int imgFrameCount = 0;
try
{
// Path to file containing multi-page tiff
// Will fail if multi-page tiff contains a single JPEG compressed frame
// Will continue if multi-page tiff contains more than 1 frame and the //
first is a CCITT4 compressed frame
image = new Bitmap(imageFil ePath);
g = image.FrameDime nsionsList[0];
imgFrameDim = new FrameDimension( g);
imgFrameCount = image.GetFrameC ount(imgFrameDi m);
}
catch (Exception exc)
{
// bad image file (corrupt or JPEG)
// Write to log
}
for (int frameIx = 0; frameIx < imgFrameCount; frameIx++)
{
try
{
// SelectActiveFra me works great if CCITT4, LZW, and other // compressed
frames
// An exception occurs as soon as it encounters JPEG
image.SelectAct iveFrame(imgFra meDim, frameIx);
pageIndex++;
int pageNumber = pageIndex + 1; // not zero based
IO.Stream str = new System.IO.Memor yStream();
image.Save(str, ImageFormat.Tif f);
Bitmap pageImage = new Bitmap(str);
images.Add(page Image);
}
catch (Exception exc)
{
forUpload = false;
// Write to the log
}
}
image.Dispose() ;
}
}
catch (Exception exc)
{
throw new AppEx("Error processing: " + documentNumber, exc);
}
}

Jul 21 '05 #1
0 3783

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

Similar topics

7
5082
by: google12 | last post by:
hi, May anyone help me? I need a lib which support .jpeg file with RGBA mode. PIL seems to support RGB and CMYK mode only... Thanks for your help.
8
5041
by: Philip Wagenaar | last post by:
..43Hi, I am trying to extract tiff images from a multipage tiff and save them to disk. This is becoming almost a nightmare for me. I have seen several examples on the net that talk about this. For example : http://www.codeproject.com/vb/net/faxeditor.asp THis example should work great. But when I even try to load the multipage tiff that came with the example I receive a general gdi+ error. The same for a TIffManager Class written in...
15
5362
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 path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
2
1646
by: Ira | last post by:
Is it possible to save a JPEG file as a Tif with specifically the JPEG compression in Vb.net? If yes, how?
2
2664
by: Asfar | last post by:
I am using GDI+ to load a tiff image and write a string to it and save the tiff image to another file. I can save the image with only LZW Compression and not abel to save with CCITT4 compression. If I use CCITT4 compression I get an invalid paramter error when saving file. The file saved with LZW compression has different resolution and tags then the orignal image. Is there a way to save the image with the same tags as the orignal...
6
3517
by: NutsAboutVB | last post by:
Hello, I am a .NET programmer and I have a JPEG image file (from digital camera) of about 109 KB's in size, when I open it and save it (without making any alterations at all, just going to File --> Save) in MS Photo Editor, the file is automatically shrunk in size to 81 KB's. When doing the same thing in MS Paint, the file is shrunk to 54 KB's. The file has the same number of pixels after both saves (as expected). My question follows...
2
12758
by: rejidasan | last post by:
Hello All, I have a MFC Dialog based application. I am not using GDI or GDI+ libraries. I need to load PNG and JPEG images in this Dialog Based application. Can you suggest me how to to do without using GDI\GDI+? Thanks in advance, Reji
2
5541
by: =?Utf-8?B?bWNpbWFnaW5n?= | last post by:
Hi, Is there any way to get . TIF, JPEG,GIF compression format. Like i have couple of images saved in my hard drive . i want to get each of these images compression format. any comments on this topic cheers mcimaging
6
7523
by: Victory | last post by:
Hi, I need to know the compression type of jpeg (jpg) files. I am using the System.Drawing.Imaging and loading the file using an Image object. The next thing i do, is to examine the propertyItems property of the object which gives me an ID, a type and Value. I am able to check for an ID of 259 (259 is the compression id) for Tiff images and check the value upper and lower significant bits of the value to see the compression. But i don't...
5
3410
by: RobT | last post by:
I'll admit, that I don't do a lot of GDI+ programming and I'm sure this is an easy answer. I'm trying to draw a couple of shapes in a web site. I can display them just fine, but on some of the fill colors are pixelated. Is there a way to render these colors at a better color depth? Dim bmp As Bitmap bmp = New Bitmap(200, 200) Dim g As Graphics g = Graphics.FromImage(bmp) g.Clear(Color.White)
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
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...
0
9386
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
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
8255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
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
6078
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();...
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
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.