Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Reading JPEG data

by Khansultant (Sexton)
on Nov 03, 2003 at 17:44 UTC ( [id://304184]=perlquestion: print w/replies, xml ) Need Help??

Khansultant has asked for the wisdom of the Perl Monks concerning the following question:

I've got a graphic artist client that wants to upload his images to the web for purchse, but he's concerned about his images being stolen and used without paying if he allows his customers to preview them.

I suggested using something like Image::Magick to composite a visible watermark on the image, and that seemed satisfactory to him, but his web host won't install binaries and hence my jam.

I'm thinking that maybe I can find a module that will parse the JPEG format and give me access to the pixels - I could pretty easily (from there) composite the watermark. Problem is, I haven't found any modules/tools that purport to doing this.

Also, preprocessing the images prior to upload is not an option. He wants security and protection, but he doesn't want to see it or do it himself - it's gotta be completely transparent in his workflow.

Any ideas greatly appreciated.

Replies are listed 'Best First'.
Re: Reading JPEG data
by talexb (Chancellor) on Nov 03, 2003 at 18:09 UTC

    What you're asking for sounds impossible, but in case I'm wrong (heh) let's review.

    • Client wants 'watermarked' images available for web visitors.
    • Client doesn't want to preprocess the images.
    • Web host doesn't permit the installation of binaries.
    Therefore, you need to either come up with a pure-Perl solution or switch web hosting companies.

    I've used convert on Linux to great success, but your post doesn't indicate whether you're on Linux or, if you are, whether convert is available. If not, perhaps the documentation at Image::Magick web site will tell you if it's pure Perl or not.

    Good luck!

    --t. alex
    Life is short: get busy!
Re: Reading JPEG data
by jdtoronto (Prior) on Nov 03, 2003 at 19:16 UTC
    If he wants visible watermarking then there are many ways to do it. Try looking at watermarker.com from some clues. Although I was involved in the field of steganography for some years as a researcher I have no personal experience with any Perl applications other than using PDL in our work.

    Their is one CPAN module: Crypt::Mimetic which may help, but this is

    If you do a goole search on "steganography perl" you will find some references to code which is out there and should be able to do your job with some adapatation - although the watermark will be invisible.

    I have heard that Image Folio is useful as a complete suite for digital image assett management. A colleague also pointed out this post on the Image-Magick mailing list which referes to a Perl programme using Image::Magick for watremarking, I am not sure if it was visible or stego.

    Good luck!

    jdtoronto

      An obvious (if naive) PDL approach would be to read images using PDL::IO::Pic, then multiply the values by a mask that was 1 for the transparent part, or (e.g.) 0.9 for the watermark part.
Re: Reading JPEG data
by waswas-fng (Curate) on Nov 03, 2003 at 19:20 UTC
    His workflow includes posting images to the website, make a program that runs on his workstation that watermarks then posts. It replaces his current upload step and does not seem like a new cumbersome step in the proccess.


    -Waswas
      I was about to sugest that very solution :-) It will make him a happy camper to know he does not have to use a ftp client.
Re: Reading JPEG data
by BrowserUk (Patriarch) on Nov 03, 2003 at 18:33 UTC

    You could look up the jpeg file format (try wotsit), and write your own jpg reader, but that would be a considerable amount of work.

    The GD module can handle jpg format, and would allow you access to the image bits for modifications. The sources for the binary component of the package are available at http://www.boutell.com/gd/. Maybe the web host would be prepared to build the library from sources for him.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Hooray!
    Wanted!

      A caveat about GD. I've been using it because my web host will not support Image::Magick. GD does everything very well, but the quality of the optimization is dicey at best. Images can look pretty chunky, regardless of how you set the params, as compared to something like a Photoshop optimization. I too would be interested in options—just wish I::M didn't have the overhead and it was more "hostable." FWIW

Re: Reading JPEG data
by jZed (Prior) on Nov 03, 2003 at 18:48 UTC
    The CPAN Image::Info module gives you access to read most of the JPEG data and has pointers to the relevant specs. The programs jpegtran and jhead (neither perl but they do work well) both do useful manipulations, I think inlcuding watermarking.
Re: Reading JPEG data
by Coruscate (Sexton) on Nov 03, 2003 at 23:20 UTC
    Since nobody else has stated what I would think to be an obvious solution, I suppose I'll mention it. To protect the previews from being stolen, why not also create a smaller, less-than-best quality image as the preview image? That way, instead of getting a 1152x864 pixel, 24 bit image, they get a half-sized, 8-16 bit image. Pick a better or worse preview image, whatever tickles your fancy :)
Re: Reading JPEG data
by bart (Canon) on Nov 04, 2003 at 03:48 UTC
    You must be extremeley cheap if your "client" thinks it's cheaper to have you program a JPEG encoder/decoder in Perl, than to look out for an ISP which allows installing binaries.

    That aside, it needn't be Image::Magick: the Imagemagick binaries are much easier to install (PerlMagick occasionally is a PITA to install), and should work fine, too.

Re: Reading JPEG data
by injunjoel (Priest) on Nov 03, 2003 at 23:24 UTC
    Greetings all,
    Here are my thoughts on the subject.
    Seeing as the web host is being uncooperative in regards to installing new pm's is there anyway you can use Image::Magick locally within the account and include something similar to:
    use lib 'place where you stored Image::Magick at'; use Image::Magick;
    within your script?
    or am I way off here?
    This is what I do when I am testing a newly created module... Though mine are no where near as complicated as Image.
    Just a thought.
    -injunjoel
Re: Reading JPEG data
by chanio (Priest) on Nov 05, 2003 at 04:01 UTC
    Here are my ideas:

    It looks that your problem is becoming a massive one, because of M$'s new Office.

    People are protecting their special proxy and not allowing everybody to download their images...

    My idea is simpler: use Flash to show images: you know perl-ming or I've seen people getting a sort of skelleton from a basic flash script and only changing the image that it loads. That would be fine with Perl, don't you think?

    Another idea is cutting the original images into thousands of pieces that would join back together in a big table of small cells. That should be programmed in order to do the exact cutting and fixing one piece in each table cell as their background image. I don't think that quality would be affected!

    Hope it helps!

      If the client can stand a short latency between upload and display:

      It will take about four hours to have a graphic artist show you how to add a watermark to an image in any of the major graphics programs like Adobe Photoshop or Corel PhotoPaint, and about 10 minutes to actually do the watermarking.

      Have him upload to a holding-file; write a script that alerts you by email of any upload; then download it, watermark it, re-upload it to the display file. Or do it once a day, etc.

      Sell it as a way to avoid heavy up-front costs to develop software, as he will only pay a small unit fee for each image as they are produced. This may create a small continuous revenue stream for you. Some day you'll pay your 14 year old nephew 1/4 the fee to do it for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://304184]
Approved by TStanley
Front-paged by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found