Image Tag Remover

Links to gaming-related tools and external resources. Feel free to promote your (RPG-related) sites here.

Moderators: dorpond, trevor, Azhrei

Post Reply
User avatar
zEal
Dragon
Posts: 944
Joined: Sun Mar 22, 2009 2:25 am

Image Tag Remover

Post by zEal »

Okay, I have a couple programs I use to strip out everything except image data from JPEGs and PNGs. Does anyone know of a nice open source, freeware, or even commercial (extra credit: cross platform) solution that would handle both formats.. and maybe more? Batch "cleaning" is a requirement.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Image Tag Remover

Post by Azhrei »

Should be pretty simple to do in Java, actually! Since Java has libraries for those two, just open up the image file, copy the image data to a new object, then write the object out.

It should also be pretty easy using the EXIF and PNG modules in Perl.

I'll take a look at using Perl if you can be specific about what you want or don't want. (I've written some Perl code that looks at the EXIF data in JPEG files and extracts date stamps, camera settings, and similar stuff.)

User avatar
zEal
Dragon
Posts: 944
Joined: Sun Mar 22, 2009 2:25 am

Re: Image Tag Remover

Post by zEal »

Yeah, I don't doubt the simplicity of such a task, I was just hoping someone might know of an existing solution; as I have too much on my plate right now to code my own.

As for what I do or don't want: I only want the minimum data required to render the image.

I've noticed that even if I explicitly tell Photoshop to not save any extraneous data, it still will. With larger images it's really a non-issue, but if you're talking about small images (~20KB) the extra crap is taking up like 40% of that.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Image Tag Remover

Post by Azhrei »

Do you have Perl installed? I have a solution for you.

It requires the Image::ExifTool module, but on Windows that can be easily installed using PPM (the Perl Package Manager).

I'm not sure what your environment is though, so I'm not sure how it should execute? How about the command line requires a directory name and a list of image files (or wildcard)? The directory is where all of the images will be stored after being processed. But it won't automatically do subdirectories (pain in the neck in any language ;)). It will handle both JPEG and PNG files (and about two dozen more, but you didn't ask for those).

I've tested it on a JPEG and it went from 137,888 bytes to 134,635 bytes. A hex dump on the resulting output doesn't show any remaining comments. Even thumbnails embedded in the image will be removed by this program.

User avatar
zEal
Dragon
Posts: 944
Joined: Sun Mar 22, 2009 2:25 am

Re: Image Tag Remover

Post by zEal »

OpenSolaris, so it depends on which version of Perl is required >.< ; but I spend a good deal of time in a Windows VM (too much time actually; too many Windows-only apps), and it has no issues with Perl... that I know of.

Not supporting sub-directories isn't an problem. Those CL parameters sound simple enough.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Image Tag Remover

Post by Azhrei »

Here you go. I had to use a .txt extension, so rename it to something pretty.

You'll need to install Image::ExifTool. If you're not familiar with that, use perl -MCPAN -e install Image::ExifTool and then go get a cup of coffee. If your installation has never had CPAN configured, there'll be about a dozen questions to answer first. Most can be defaulted by hitting Enter, but it's a good idea to pick a CPAN mirror geographically near you. And if you don't install it as root, you can only configure the module for your own use. I don't recall if the module requires a compiler, but I don't think it does, although it does require a make command.

I just tested it by trying:

Code: Select all

./cleanup.pl t Misc/*.jpg
And it correctly stripped off the Misc/ from the input filename and then dumped the result into the ./t directory.
Attachments
cleanup.txt
Perl script to clean image files
(645 Bytes) Downloaded 53 times

User avatar
zEal
Dragon
Posts: 944
Joined: Sun Mar 22, 2009 2:25 am

Re: Image Tag Remover

Post by zEal »

Very cool, thanks man. :)

Post Reply

Return to “Links & External Resources”