flemmingp Posted March 31, 2013 Share Posted March 31, 2013 Hi all I have this where I aplly filer to an webcam image and save it... BUT hov can I save it with numbers _0001.jpg , _0002.jpg this is my code $image = imagecreatefromjpeg($image); //imagefilter($image, IMG_FILTER_NEGATE); imagefilter($image, IMG_FILTER_BRIGHTNESS, 30); imagefilter($image, IMG_FILTER_CONTRAST, -10); imagejpeg($image, 'cam-corrected.jpg'); imagedestroy($image); echo '<img src="cam-corrected.jpg" alt="Image Effect Applied" />'; REGARDS Quote Link to comment https://forums.phpfreaks.com/topic/276345-copy-image-with-increase-number/ Share on other sites More sharing options...
Barand Posted March 31, 2013 Share Posted March 31, 2013 BUT hov can I save it with numbers _0001.jpg , _0002.jpg By retrieving the last number used, incrementing, then resaving. Quote Link to comment https://forums.phpfreaks.com/topic/276345-copy-image-with-increase-number/#findComment-1422076 Share on other sites More sharing options...
flemmingp Posted March 31, 2013 Author Share Posted March 31, 2013 Thanks for reply Could you please be more specfic I mean that I have to aplly sometning to this imagejpeg($image, 'cam-corrected.jpg'); for save with increase of numbers R Quote Link to comment https://forums.phpfreaks.com/topic/276345-copy-image-with-increase-number/#findComment-1422079 Share on other sites More sharing options...
ignace Posted April 1, 2013 Share Posted April 1, 2013 (edited) Get the filename of the image (without the extension) using pathinfo. Then find all images matching the earlier retrieved filename using glob. Sort the results in reverse order (high to low) using usort and grab the first one using array_shift, grab the number using substr and strrpos (pass _ as needle), convert to an integer using intval, increment, and generate the new filename using sprintf. Store it using file_put_contents. Edited April 1, 2013 by ignace Quote Link to comment https://forums.phpfreaks.com/topic/276345-copy-image-with-increase-number/#findComment-1422234 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.