Khalsa Labs

Extracting PNG images from a file

Want to extract multiple PNG images from a file?

No need to extract images one by one using HEX Editors. Now you can extract all PNG images from a files into one folder using the following PHP script.


 

<form enctype="multipart/form-data" method="POST">
File: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
<?php
//script by skillsyard.in

error_reporting(0);

$f = file_get_contents($_FILES[uploaded][tmp_name],"ab");

$count = preg_match_all( '|x89x50x4Ex47.*?ENDxAEx42x60x82|s' , $f, $pngc);
echo $count;

if($is_dir("img"))
{
mkdir("img");
}

for($i=0; $i<$count; $i++)
{
preg_match_all( '|x89x50x4Ex47.*?IENDxAEx42x60x82|s' , $f, $pngc);

//saves <number>.png in 'img' directory. eg: 58.png
$file='img/'.$i.'.png';
$fh=fopen($file,"ab");
fwrite($fh,$pngc[0][$i]);
fclose($fh);
}
?>

For example, Skin files of Opera Mini S60 (skin-hqvga-multi.rsc, skin-hvga-multi.rsc, skin-qvga-multi.rsc) contains PNG images. You can see HEX codes of those images using HEX Editors like HxD – Hex Editor.

But with this PHP script, you can upload the file containing PNG images and get all PNG images in “img” directory.

Download the php script file and upload it to your Php WebServer to use it.

[button url=”http://khalsalabs.com/wp-content/uploads/2012/05/extractpng.zip” size=”medium” textcolor=”#ffffff”]Download extractpng.zip[/button]

The following two tabs change content below.

MadGuyyy

Latest posts by MadGuyyy (see all)

want to comment ??

Your email address will not be published. Required fields are marked *