Convert Tif format to JPG format

Source: Internet
Author: User

Recently, a WPF client in CEB format is being downloaded. You need to download the CEB format from ftp, convert the CEB format to JPG format, and then display it on the webpage. The entire project is 100,000, because the company's CEB format software was bought by Beijing Big founder Apache, we called and wanted Beijing Big founder to help us with such a plug-in. However, we did not expect the price to be 100,000 directly after the call, there is no way to make the entire project only 100,000, so you have to do it yourself. The specific steps are as follows:

1. Install a virtual printer.

2. install Apache Software.

3. Run the command to call Apache print.

4. Obtain the virtual printer stream.

5. Convert TIF to JPG.

6. Generate a JPG file.

The following describes how to convert filesCodeWrite down:

Public bool tif2jpg (string tifpath, string tifname) S
{
Try
{
Int Len = tifpath. lastindexof (". tif ");
String filename2 = tifpath. substring (0, Len );
String filepath = filename2.substring (0, filename2.lastindexof ('\') + 1 );
Filestream stream = file. openread (tifpath );
Bitmap BMP = new Bitmap (Stream );
System. Drawing. Image image = BMP;
Guid objguid = image. framedimensionslist [0];
Framedimension objdimension = new framedimension (objguid );
Int totframe = image. getframecount (objdimension );
Count = totframe;
For (INT I = 0; I <totframe; I ++) // generate multiple images cyclically
{
Image. selectactiveframe (objdimension, I );
Image. Save (filepath + tifname + "(" + I + ").jpg", imageformat. JPEG );
}
BMP. Dispose ();
Image. Dispose ();
Stream. Close ();
File. Delete (tifpath );

return true;
}< br> catch (exception)
{< br> return false;
}< BR >}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.