GDI+ output directly to CMYK JPG?

Posted on 2012-08-30
Medium Priority
Last Modified: 2012-09-11
I have an ASP.NET application using GDI+ to create a Bitmap to be displayed on the client's browser (as a JPG in an Image), and can also be downloaded as a JPG.

My problem is that the image will need to be printed, and a lot of commercial printers will only accept JPGs with colors specified in CMYK, not RGB.

I have looked at using a tool like ImageMagick to convert the RGB JPG to CMYK JPG after the former has been created... but this takes more time than the creation of the image to begin with (performance is an issue).

Is there anyway to output a CMYK JPG file directly from GDI+ ? I've been looking around the web, but have failed to find an answer.

Question by:futuremoose
  • 2
LVL 83

Accepted Solution

CodeCruiser earned 1500 total points
ID: 38349147

Author Comment

ID: 38389345
Ok... sorry to take so long getting back to this thread, but I only now finally got a chance to try out the suggestions above. The first link led to some code that claimed to work, but I could not get it to work... however, it led me eventually to another example posted here


which I did get to work (code is just below). The output file's metadata confirms that the PhotometricInterpretation is "CMYK". Colors may be kind of messed up, but now I'll look for a way to apply a Color Profile (ICM or ICC) file. If I have trouble, I'll open another thread.

Anyhow, thanks CodeCruiser... I'll mark your comment as solution.

Imports System.Windows.Freezable
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.IO

Public Class Form1

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ' this example from: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/0a4fecba-6212-4e72-9e10-7874c6327e7a/
        ' this one does work... kind of. Colors seem messed up, and file size also much larger (as expected).
        Dim imageStream As Stream = New FileStream("c:\temp\a.jpg", FileMode.Open, FileAccess.Read, FileShare.Read)
        Dim myBitmapSource As BitmapSource = BitmapFrame.Create(imageStream)
        Dim newFormatedBitmapSource As FormatConvertedBitmap = New FormatConvertedBitmap()
        newFormatedBitmapSource.Source = myBitmapSource
        newFormatedBitmapSource.DestinationFormat = PixelFormats.Cmyk32
        Dim encoder As BitmapEncoder = New TiffBitmapEncoder()
        Dim cmykStream As Stream = New FileStream("C:\temp\a_CMYK.tif", FileMode.Create, FileAccess.Write, FileShare.Write)
    End Sub

End Class

Open in new window


Author Closing Comment

ID: 38389348
Example pointed to did not actually work, but it led to one that did, which is good enough for me.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

840 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