Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ofTheo opened this issue May 11, 2011 · 10 comments

Comments

@ofTheo
Copy link
Member

ofTheo commented May 11, 2011

No description provided.

@ghost ghost assigned bilderbuchi Oct 8, 2012
@bilderbuchi
Copy link
Member

I have assigned myself to try and reproduce this.

@bilderbuchi
Copy link
Member

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!

@minusplusminus
Copy link

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
Copy link
Member

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

@minusplusminus
Copy link

Used the imagePickerExample:

      void testApp::update(){
        if(camera) {
        if(camera->imageUpdated){

        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;

        camera->close();
        photo.saveImage(ofxiPhoneGetDocumentsDirectory()+"imageInUpdate.png");
        photo.saveImage(ofxiPhoneGetDocumentsDirectory()+"imageInUpdate.jpg");
        delete camera;
        camera = NULL;
        runOnce = true;
    }
  }
 }

@bilderbuchi bilderbuchi reopened this Apr 9, 2013
@bilderbuchi
Copy link
Member

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

@minusplusminus
Copy link

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

@lewezero
Copy link

Hi,

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);

    pixels.allocate(texData.width,texData.height,ofGetImageTypeFromGLType(texData.glType));
    bind();
    glGetTexImage(texData.textureTarget,0,texData.glType,GL_UNSIGNED_BYTE, pixels.getPixels());
    unbind();

    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.

@minusplusminus
Copy link

Seems logical 👍

@kylemcdonald
Copy link
Contributor

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
Projects
None yet
Development

No branches or pull requests

5 participants