Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8571309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:45:12+00:00 2026-06-11T18:45:12+00:00

I am resizing many jpeg images using Apache Sanselan which also deals with CMYK

  • 0

I am resizing many jpeg images using Apache Sanselan which also deals with CMYK colors.
I have a problem when trying to convert jpeg images that has an alpha channel… when doing it the result is an image with different colors, and i guess that java somehow handles these type of images as a different color format.
As i said, the RGB resizing works fine as well as CMYK. ARGB images turn out with different colors.

An example:
Before resizing

After resizing

Any suggestions? Can i force somehow ignore the alpha channel and handle the image as an RGB image? or convert it to be an RGB image without losing the real colors?

The code that handles this image is:

    ImageInputStream stream = ImageIO.createImageInputStream(file);
    Iterator<ImageReader> iter = ImageIO.getImageReaders(stream);
    while (iter.hasNext()) {
        ImageReader reader = iter.next();
        reader.setInput(stream);

        BufferedImage image = null;
        ICC_Profile profile = null;
        try {
            image = reader.read(0);

        } catch (IIOException e) {
            ... (CMYK conversion if needed)
        }

        return image;
    }
    return null;

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:45:13+00:00Added an answer on June 11, 2026 at 6:45 pm

    I found a good solution here (first solution worked great):

    problem using ImageIO.write jpg file

    Edit:
    There is a new open source library which supports CMYK processing.
    All you need to do is to add the dependency to your project and a new reader will be added to the list of readers (while the known JPEGImageReader can’t deal with CMYK).
    You will probably want to iterate over these readers and read the image using the first reader which doesn’t throw exception.
    This package is a release candidate, but i am using it and it solved a huge problem that we had hard time dealing with.

    http://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-jpeg/3.0-rc5

    You can do the iteration this way to get the BufferedImage, and after you got that, the rest is easy (you can use any existing image converting package to save it as another format):

    try (ImageInputStream input = ImageIO.createImageInputStream(source)) {
    
            // Find potential readers
            Iterator<ImageReader> readers = ImageIO.getImageReaders(input);
    
            // For each reader: try to read
            while (readers != null && readers.hasNext()) {
                ImageReader reader = readers.next();
                try {
                    reader.setInput(input);
                    BufferedImage image = reader.read(0);
                    return image;
                } catch (IIOException e) {
                    // Try next reader, ignore.
                } catch (Exception e) {
                    // Unexpected exception. do not continue
                    throw e;
                } finally {
                    // Close reader resources
                    reader.dispose();
                }
            }
    
            // Couldn't resize with any of the readers
            throw new IIOException("Unable to resize image");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have recently started using ImageResizer.Net over GDI+ for dynamically resizing images on our
Currently i have system that's do resizing and creating as many images as needed
I have read many answers to questions about dynamically resizing NSWindows and nothing has
I have some problems resizing a div with ID mask which I use to
I have a simple images resizing script that works great for JPEGs, but not
Possible Duplicate: Image resizing web service many web provider have support for php but
Yet again another issue with resizing, like many others I have used the CreateParams
what i am trying to make is a view which also has a tableview
I have built a system which downloads images from a bunch of URLs, depending
Ok I have seen many posts on this script. Which can be found..... http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.