473,606 Members | 3,113 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 3766

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

Similar topics

7
5078
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
5034
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
5325
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
1631
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
2656
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
3501
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
12729
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
5533
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
7506
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
3401
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
8036
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
7978
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,...
1
8126
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
8317
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...
0
6796
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...
0
3948
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...
1
2454
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
1
1572
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1313
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.