Convert jpeg file in png and then zip without making copy in php
To convert jpeg file in png and then zip without making copy with using PHP you have to go through the steps which are described below:
Step 1 : First you have to copy code in your file which is given below and then change path name as per your requirement.
Code :View Code PHP
1 2 3 4 5 6 7 8 9 10
$file = "../assets/test.jpg"; // capture output into the internal buffer ob_start(); $img = imagecreatefromjpeg($file); imagepng($img); // get contents from the buffer $contents = ob_get_clean(); $zip = new ZipArchive(); $zip->open('archive.zip', ZipArchive::CREATE); // and put them in the zip file... $zip->addFromString('name_in_the_zip.png', $contents);