Writting a Jpeg image with Raspberry pi

Hi,

Im trying to write a jpeg image buffer to send it over a network, but cinder throws this exception when doing so:

ci::OStreamMemRef os = ci::OStreamMem::create();
ci::DataTargetRef target = ci::DataTargetStream::createRef(os);
ci::writeImage( target, *surface, ci::ImageTarget::Options().quality(0.1), "jpeg" );

the error:

|fatal  | void cinder::app::AppBase::executeLaunch()[197] Uncaught exception, type: cinder::ImageIoExceptionUnknownExtension, what: Could not create target for image with extension: jpeg
terminate called after throwing an instance of 'cinder::ImageIoExceptionUnknownExtension'
  what():  Could not create target for image with extension: jpeg
Aborted

the “fun” thing is that .png’s works

any help is appreciated =)

thanks!
bye

I think it is not supported at the moment. I might be wrong, but ImageIo in linux is handled by stb, and only png, bmp, tga, and hdr image targets are registered:

Yeah, I guess that stb it self does not support I will try to use this one instead:

thanks!

Ooh, that’d make a nice cinderblock (ImageSource / ImageTarget impls using tinyjpeg)

cheers,
Rich

Cool! I did some testing and it looks pretty straightforward

Out of curiosity, wouldn’t a pull request make more sense?

bye

Out of curiosity, wouldn’t a pull request make more sense?

To my mind, this is where cinderblocks shine - you can work on additions outside of the core codebase, test them, improve them, etc. Once it is proven to be a useful tool, then getting it into core is a simple process.

2 Likes

Cool
=)

it was rather easy actually:
https://github.com/Hperigo/Cinder-TinyJpeg

unfortunately the lib only supports RGB images.

thank! bye

Nice! AFAIK jpeg doesn’t support an alpha channel, and not supporting B/W seems of less concern to me, so you’ve hit the big use case. Thanks for wrapping this up.

Now if you add a cinderblock.xml and a snazzy icon, it’ll pop up on aggregate lists like this one. :slight_smile:

cool!

yeah, actually in my case I was trying to send just the luma channel of an image. But I guess the rgb image is fine too

just updated the repo with the xml you mentioned!