Small jpg manipulation library?

Jun 18, 2006 9 Replies

I have a simple request:



I need a small proggie that will let me rotate a 640x480 jpeg image 180 degrees, and add a short piece of text (about 2 lines, maybe 25 chars each) to the image itself.



My embedded sytem only has about 500K of flash left, so I really need something that fits in that space.



I can create the image as raw RGB, do the manipulations, and then save it as a jpeg if that would help.



I would appreciate any pointers....



Thanks,


--Yan


o__ ,>/'_ o__ (_)\(_) ,>/'_ o__ Yan Seiner, PE (_)\(_) ,>/'_ o__ Certified Personal Trainer (_)\(_) ,>/'_ o__ Licensed Professional Engineer (_)\(_) ,>/'_ Who says engineers have to be pencil necked geeks? (_)\(_)

How much RAM you got? You need to store two fully decompressed images at least.

The images should only take up ~1MB uncompressed; I have 32 MB total and

15-16MB free:

root@apollo:/bin# free total used free shared buffers Mem: 30556 15368 15188 0 1520

So RAM shouldn't be an issue. I figured out I can do the jpeg rotation with jpegtran; now I just need to find something I can use to add a watermark....

--Yan

o__ ,>/'_ o__ (_)\(_) ,>/'_ o__ Yan Seiner, PE (_)\(_) ,>/'_ o__ Certified Personal Trainer (_)\(_) ,>/'_ o__ Licensed Professional Engineer (_)\(_) ,>/'_ Who says engineers have to be pencil necked geeks? (_)\(_)

Is the text static? We have a program to overlay one image on another, If you first create the text overlay image elsewhere. You can just screen capture from a word processor. Is your target x86, arm or what?

No, the text is dynamic. It is generated on the fly from GPS data and a database lookup.

I am trying to avoid using a lot of resources with font-rendering stuff; I really just want a stamp much like the date and time stamp you can put on digital photographs taken with a regular camera.

--Yan

OK, if you provide the character images (one jpg per character), we can give you a tool to overlay it on an image. We have a program:

jpg -i old.jpg -c blue -m mask.jpg -o new.jpg

Will work on: new_program -x 100 -y 100 -i old.jpg-o mask.jpg -t text

What is your target cpu?

mips. This is for an app running on OpenWrt - a Linksys WRTSL54GL wireless router, with a webcam and a GPS attached.

--Yan

o__ ,>/'_ o__ (_)\(_) ,>/'_ o__ Yan Seiner, PE (_)\(_) ,>/'_ o__ Certified Personal Trainer (_)\(_) ,>/'_ o__ Licensed Professional Engineer (_)\(_) ,>/'_ Who says engineers have to be pencil necked geeks? (_)\(_)

OK, we can deal with mips later. We also want to have text overlays. We need character bit maps for letters and symbols, We already have numbers. They should be like:

"* * ", "* * * * ", "* * * * ", "* * * * ", "* ** * ", "* * ", "* * ", "* * ", "* * ", "* * "

This is just a on-time program to generate the intermediate structure, so don't worry about efficience.

If you can help, I'll set you up with an account on our server. Do you want to do it?

Why reinvent the wheel?

formatting link

It's java, but with this being a one-off, it doesn't really matter.

I can help some. Remove the obvious from my email address to contact me directly. I'm going out of town today, and when I return I may have to go on yet another business trip (overseas, yet) so my time for the next 3-4 weeks is severly limited, though.

--Yan

o__ ,>/'_ o__ (_)\(_) ,>/'_ o__ Yan Seiner, PE (_)\(_) ,>/'_ o__ Certified Personal Trainer (_)\(_) ,>/'_ o__ Licensed Professional Engineer (_)\(_) ,>/'_ Who says engineers have to be pencil necked geeks? (_)\(_)

Java (jpeg Jre) is heavy. It's much easier to strip down jpeg lib. We have about 150K binary so far. The following is an example (for our dance teacher) for jpg resolution reductions. We want to overlay both texts and images on it as well.

formatting link

-rw-r--r-- 1 root wheel 133 Jun 19 19:00 Makefile

-rw-r--r-- 1 root wheel 38603 Jun 19 19:02 a1.jpg

-rw-r--r-- 1 root wheel 24366 Jun 19 19:02 a2.jpg

-rw-r--r-- 1 root wheel 14051 Jun 19 19:05 b1.jpg

-rw-r--r-- 1 root wheel 14510 Jun 19 19:05 b2.jpg

-rw-r--r-- 1 root wheel 5353 Jun 19 19:05 c1.jpg

-rw-r--r-- 1 root wheel 5491 Jun 19 19:05 c2.jpg

-rw-r--r-- 1 root wheel 38 Jun 19 19:00 data

-rw-r--r-- 1 root wheel 604 Jun 19 19:06 index.html

-rwxr-xr-x 1 root wheel 124878 Jun 19 18:55 jpg

-rwxr-xr-x 1 root wheel 2635 Jun 19 19:29 main.php

-bash-2.05b# more Makefile all: ./jpg -i a1.jpg -o b1.jpg -r 2 ./jpg -i a2.jpg -o b2.jpg -r 2 ./jpg -i b1.jpg -o c1.jpg -r 2 ./jpg -i b2.jpg -o c2.jpg -r 2

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required