Solved

C# system.drawing.image.save .tiff actually .png (or at least photoshop CS3 thinks so)

Posted on 2009-05-15
6
2,729 Views
Last Modified: 2013-12-17
I am saving an image from a C# program developed in Visual Studio 2005 .NET using the system.drawing.image.save to save it as a .tiff file.  I can open it in MS Paint, and any other program I've tried EXCEPT for photoshop (cs3 and cs4) - photoshop says its an invalid file format.  If I rename it from image.tiff to image.png then photoshop opens it.  If I open the image.tiff in paint and resave it as a .tiff, then photoshop also opens it.  It would seem as if VS2K5 is saving the image as a .png even though I specify the format as .tiff.  Has anyone seen this behavior before or have any ideas?
0
Comment
Question by:BSL43
  • 4
  • 2
6 Comments
 
LVL 39

Expert Comment

by:abel
ID: 24397012
Photoshop is correct. MsPaint is lenient and checks the header info of the image, which is probably a BMP or WMF if you do not specify a format.

It is not possible to store an image as a TIFF file, at least not with .NET without having third party libraries to help you. In the screenshot is the list of available image types.

ScreenShot282.png
0
 
LVL 39

Expert Comment

by:abel
ID: 24397085
However, using ImageCodecs, which are installed on any windows system, it is possible with a workaround. Here's one way for multipage tiffs (sorry, it is reading, not writing): http://www.bobpowell.net/addframes.htm

and here is a way for splitting a tiff image: http://www.codeproject.com/KB/GDI-plus/tiffmanager.aspx

and finally, the one and only class for tiff manipulation: http://kseesharp.blogspot.com/2007/12/class-for-tiff-manipulation.html
0
 

Author Comment

by:BSL43
ID: 24397112
I understand what you are saying (I think), but they why does Tiff show up in your screen shot of available file types above....  Also, what 3rd party library would you recommend then for VS2K5 .Net c# development?  Thanks.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 39

Accepted Solution

by:
abel earned 250 total points
ID: 24397424
> but they why does Tiff show up in your screen shot of available file types above....

haha, indeed, you are right. I must be blind, and very stupid (today only, lol). I looked at it a couple of times, but now: it is there. However, I use VS 2008, I'll have to check this for 2005. Can you show me the code of how you save the file? And maybe you can add a little resultant *.tiff file here (rename it to .txt, otherwise the "attached file" doesn't cooperate).
0
 

Author Comment

by:BSL43
ID: 24398011
Okay, so you got me thinking.  Sure enough in several locations I didn't specify the imageformat .tiff along with the save so even though I had the correct save, vs was defaulting it to a png compression with a .tiff extension.  Thanks.  
0
 
LVL 39

Expert Comment

by:abel
ID: 24398133
ah, good to know. So, this means: if you do not specify the format, the format is PNG.

glad it works now :)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to prevent website from publishing with errors 9 46
2 questions 10 25
Search an image for an image 3 30
Cant save 3D 4 19
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Read about why website design really matters in today's demanding market.
In this tutorial viewers will learn how to create a Photoshop action to apply adjustments and effects to multiple images. Open a photo for editing in Photoshop: Open the Actions window by going to Window > Actions: Start a new action by selecting th…
Make a selection using the pen tool to trace the selection. Then alter the color of the selection by using the color balance option in Adobe Photoshop.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question