


$("#image-file").change(function()That's all you need to create an Ajax based image uploader with PHP ImageMagick features to resize normal images as well as GIF animated images. Var image_filters = /^(?:image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\/x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/x\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump)$/i Regex filter to allow only image file types Var max_file_size = 2194304 //Max file size allowed (2MB) Var ajax_url = "upload_resize.php" //path to upload_resize.php Upload Box Let's create an HTML upload form, images will be uploaded with Ajax requests so we will be using jQuery later, hence there's no regular HTML form to trigger upload, instead we want to upload image automatically as soon as the user chooses a file with. If you are on shared hosting, most companies already offer ImageMagick to their clients, so if you face some problems make sure ImageMagick is available. ImageMagick Installation ImageMagick is not always available, but installation is pretty straight forward, for example here's a guide to install ImageMagick in ubuntu 16.04, similar resources on ImageMagick installation can be found on the internet for different OS. Today we are going to create a very simple Ajax based image resize script using ImageMagick (PHP) and jQuery. Written by Saran on October 30, 2014, Updated December 8, 2018ImageMagick is great image processing for PHP, with ImageMagick you can resize your image, crop and do many other things in a very simple manner, it supports numerous image formats.
