User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 402,918 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,204 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 291 | Replies: 9
Reply
Join Date: Jul 2008
Posts: 32
Reputation: TheBuzzer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TheBuzzer TheBuzzer is offline Offline
Light Poster

need help reading cmyk jpgs

  #1  
Jul 24th, 2008
ImageIO.read does not work for jpgs in cmyk

trying to find a method to read it been searching on google but found lot of different results. Maybe one of you know a easy method to do this.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,242
Reputation: peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough 
Rep Power: 10
Solved Threads: 270
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: need help reading cmyk jpgs

  #2  
Jul 24th, 2008
You may want to work with Java Advanced Imaging API or Java - ImageIO. Both have very useful forums on java.net (JAI, ImageIO)
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Join Date: Jul 2008
Posts: 32
Reputation: TheBuzzer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TheBuzzer TheBuzzer is offline Offline
Light Poster

Re: need help reading cmyk jpgs

  #3  
Jul 24th, 2008
i see the libraries. but still no clue where to start

all I want is to read a image to a BufferedImage of a jpeg with cmyk

if not possible than I would most likely go by converting a image with some class than make that class output the image into a bytearray stream.

looking at jaiimageio but not sure can i use it to convert a image.
Reply With Quote  
Join Date: Jul 2008
Posts: 32
Reputation: TheBuzzer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TheBuzzer TheBuzzer is offline Offline
Light Poster

Re: need help reading cmyk jpgs

  #4  
Jul 24th, 2008
well i found a code that uses jai but the returned byte array image color isnt right.

    public static BufferedImage convertCMYKtoRGB(byte[] ba) throws Exception {

        int[] bitsCMYK = {8, 8, 8, 8};
        ICC_ColorSpace csCMYK = new ICC_ColorSpace(ICC_Profile.getInstance(SharedData.WRITELOCATION + "images\\pdf\\CMYK.pf"));

        ColorModel colorModelCMYK = new ComponentColorModel(csCMYK, bitsCMYK, false, false, java.awt.Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
        ImageLayout cmykLayout = new ImageLayout();
        cmykLayout.setColorModel(colorModelCMYK);
        RenderingHints rh = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, cmykLayout);

        ByteArraySeekableStream bais = new ByteArraySeekableStream(ba);
        ParameterBlock params = new ParameterBlock();
        params.add(bais);
        RenderedOp op = JAI.create("stream", params, rh);
        bais.close();

        ColorSpace csRGB = null;
        csRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        ColorModel colorModel = new ComponentColorModel(csRGB, bitsCMYK, false, false, java.awt.Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
        ImageLayout il = new ImageLayout();
        il.setSampleModel(colorModel.createCompatibleSampleModel(op.getWidth(), op.getHeight()));
        RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);
        ParameterBlock pb = new ParameterBlock();

        pb.addSource(op).add(colorModel);
        il = new ImageLayout();
        il.setSampleModel(colorModel.createCompatibleSampleModel(op.getWidth(), op.getHeight()));
        hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);

        RenderedOp opNeu = JAI.create("ColorConvert", pb, hints);

        BufferedImage img = opNeu.getAsBufferedImage();
        return img;
    }
Last edited by TheBuzzer : Jul 24th, 2008 at 4:58 pm.
Reply With Quote  
Join Date: Jul 2008
Posts: 32
Reputation: TheBuzzer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TheBuzzer TheBuzzer is offline Offline
Light Poster

Re: need help reading cmyk jpgs

  #5  
Jul 24th, 2008
I also tried

                        PlanarImage inImage = JAI.create("fileload",SharedData.WRITELOCATION + (String) theorder.get("ordertype") + "Data\\" + String.valueOf((Integer) theorder.get("hiddenkey")) + "\\logos\\cappreview\\" + (String) theorder.getItem(item).get("previewfilename"));
                        BufferedImage realimage = inImage.getAsBufferedImage();

the color isnt right for this too.
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,660
Reputation: Ezzaral is a glorious beacon of light Ezzaral is a glorious beacon of light Ezzaral is a glorious beacon of light Ezzaral is a glorious beacon of light Ezzaral is a glorious beacon of light 
Rep Power: 11
Solved Threads: 262
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Maven

Re: need help reading cmyk jpgs

  #6  
Jul 24th, 2008
Some of the info in this bug report might be of use:
http://bugs.sun.com/bugdatabase/view...bug_id=4799903
Last edited by Ezzaral : Jul 24th, 2008 at 5:13 pm.
Reply With Quote  
Join Date: Jul 2008
Posts: 32
Reputation: TheBuzzer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TheBuzzer TheBuzzer is offline Offline
Light Poster

Re: need help reading cmyk jpgs

  #7  
Jul 24th, 2008
well i can't figure out how to do this.

using jai i can read the jpg but cant get the colors rigth.
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,660
Reputation: Ezzaral is a glorious beacon of light Ezzaral is a glorious beacon of light Ezzaral is a glorious beacon of light Ezzaral is a glorious beacon of light Ezzaral is a glorious beacon of light 
Rep Power: 11
Solved Threads: 262
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Maven

Re: need help reading cmyk jpgs

  #8  
Jul 24th, 2008
Did you read through some of the work-arounds mentioned in that bug report to translate the color space?
Reply With Quote  
Join Date: Jul 2008
Posts: 32
Reputation: TheBuzzer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TheBuzzer TheBuzzer is offline Offline
Light Poster

Re: need help reading cmyk jpgs

  #9  
Jul 24th, 2008
Originally Posted by Ezzaral View Post
Did you read through some of the work-arounds mentioned in that bug report to translate the color space?



ya but the work round use other stuff i dont even know so i cant even use those functions
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,242
Reputation: peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough 
Rep Power: 10
Solved Threads: 270
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: need help reading cmyk jpgs

  #10  
Jul 25th, 2008
Just compare it wit javaio API
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Java Forum

All times are GMT -4. The time now is 4:08 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC