saving an image with the image quality flag set to high or best causes empty jpegs. #569

ofTheo opened this Issue May 11, 2011 · 10 comments


None yet
5 participants

ofTheo commented May 11, 2011

No description provided.

@ghost ghost assigned bilderbuchi Oct 8, 2012


bilderbuchi commented Oct 8, 2012

I have assigned myself to try and reproduce this.


bilderbuchi commented Jan 12, 2013

I tried to reproduce this, but I can't.
Ubuntu 12.10, current OF develop. Modified the imageSaverExample to store jpg instead of png, the default compression level of ofImage::saveImage is already OF_IMAGE_QUALITY_BEST, so there was no need to change that.
@ofTheo, I suspect this bug was solved in the meantime (it's 2 years old). I'll close this, and if you still observe this bug, re-open it with a repro procedure. :-) Thanks!

Have this problem in IOS. I can store an image like a PNG, but a JPG is always 0 bytes.
I've used ofImage.saveImage()


bilderbuchi commented Apr 8, 2013

@ikillbombs please post some code and/or detailed reproduction steps which show your problem.

Used the imagePickerExample:

      void testApp::update(){
        if(camera) {

        int cameraW = camera->width;
        int cameraH = camera->height;
        unsigned const char * cameraPixels = camera->pixels;

        photo.setFromPixels(cameraPixels, cameraW, cameraH, OF_IMAGE_COLOR_ALPHA);

        imgPos.x = ofGetWidth()/2;
        imgPos.y = ofGetHeight()/2;

        delete camera;
        camera = NULL;
        runOnce = true;

@bilderbuchi bilderbuchi reopened this Apr 9, 2013


bilderbuchi commented Apr 9, 2013

Thanks, I reopened the issue. @ofTheo @julapy could you take a look at this?

I think it is a memory problem. Some other code I use gives a memory error during the usage.


I had similar problems related to saving images (although for me it doesn't save no matter what quality I set). I noticed two issues here: memory problems are probably caused by wrong GL_PACK_ALIGNMENT value, the following change in ofTexture::readToPixels helped in my case:

    GLint prevAlignment;
    glGetIntegerv(GL_PACK_ALIGNMENT, &prevAlignment);
    glPixelStorei(GL_PACK_ALIGNMENT, 1);

    glGetTexImage(texData.textureTarget,0,texData.glType,GL_UNSIGNED_BYTE, pixels.getPixels());

    glPixelStorei(GL_PACK_ALIGNMENT, prevAlignment);

As to empty JPEGs, I noticed that the alpha channel is the problem (you can render to an FBO with GL_RGB format to get rid of it). Sounds reasonable since JPEG doesn't support alpha, but the framework should at least warn you about this.

Seems logical 👍


kylemcdonald commented Dec 12, 2014

can't recreate this issue, closing unless @openframeworks/ios can reproduce (sounds like a platform-specific bug).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment