Writting a Jpeg image with Raspberry pi


#1

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


#2

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:


#3

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

thanks!


#4

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

cheers,
Rich


#5

Cool! I did some testing and it looks pretty straightforward

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

bye


#6

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.


#7

Cool
=)

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

unfortunately the lib only supports RGB images.

thank! bye


#8

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:


#9

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!