Posts

Showing posts from May, 2017

How to generate thumbnail from image and also apply watermark using php

Please refer below code for generate thumbnail from image and also apply watermark using php createThumbnail ( 'sign_in.png' ) ; function createThumbnail ( $filename ) { $path_to_thumbs_directory = 'thumbs/' ; $mimeType = mime_content_type ( $filename ) ; if ( $mimeType == "image/png" ) { $im = imagecreatefrompng ( $filename ) ; } else if ( $mimeType == 'image/gif' ) { $im = imagecreatefromgif ( $filename ) ; } else if ( $mimeType == 'image/jpg' || $mimeType == 'image/jpeg' ) { $im = imagecreatefromjpeg ( $filename ) ; } $ox = imagesx ( $im ) ; $oy = imagesy ( $im ) ; $nx = 256 ; $ny = 256 ; $nm = imagecreatetruecolor ( $nx , $ny ) ; imagecopyresized ( $nm , $im , 0 , 0 , 0 , 0 , $nx , $ny , $ox , $oy ) ; if ( ! file_exists ( $path_to_thumbs_directory )) { if ( ! mkdir ( $path_to_thumbs_directory )) { die ( "T