PHPDeveloper.orghttp://www.phpdeveloper.org
Up-to-the Minute PHP News, views and communityen-usTue, 31 Mar 2015 17:06:12 -050030http://www.phpdeveloper.org/news/20731http://www.phpdeveloper.org/news/20731
On the CodeGeekz site there's a new post showing you how to use the Imagick extension and a custom library to crop images based on their entropy (keeping the "busiest" part of the image).

The need to resize and crop images in order to create thumbs, is a very common scenario for most websites. For example a blog like this one uses images in the content of the posts, images which at some point are used to create a thumb for the homepage. In most cases, the thumb's dimensions are not dynamic but are static throughout the website in order to better fit the template. This however creates a major problem when we try to automatically resize and crop our images in the desired dimensions.

He starts with an example of the normal kind of cropping based on a given height and width. He points out an issue with "smart cropping" and resizing the image with the cropping is done. Instead, he's made use of Imagick in his library to produce a better cropped image based on the parts of the image with the most entropy.

Link: http://codegeekz.com/cropping-images-entrop/]]>Mon, 03 Feb 2014 11:25:42 -0600http://www.phpdeveloper.org/news/19537http://www.phpdeveloper.org/news/19537
PHPMaster.com has a new tutorial posted showing you how to crop and resize images with the help of the ImageMagick functionality that can be added to PHP (via this extension).

If your website allows users to upload photos, image cropping/resizing functionality certainly comes in handy. But users might not have access to image manipulation tools like Photoshop, so by providing a cropping/resizing feature you can allow users to upload photos from any device (e.g. tablets or phones) without them having to worry about the the final size. Furthermore, you can create different versions of the same image and also allow users to crop specific portions of uploaded picture. In this article I'll show you how to create an image cropping tool with the help of the ImageMagick PHP extension.

The post shows the use of the "cropimage" function to trim down an image from its original size and "thumbnailImage" to shrink down the image to make a thumbnail. Also included is the code (both the PHP and the HTML form) to handle file uploads and automatically create a thumbnail image. It outputs the image to the browser and asks the user to select the portion they want thumbnailed (with this jQuery plugin helping).

Link: http://phpmaster.com/crop-and-resize-images-with-imagemagick]]>Thu, 02 May 2013 12:14:51 -0500http://www.phpdeveloper.org/news/16150http://www.phpdeveloper.org/news/16150
Smashing Magazine has a new post today about using jQuery and GD to manipulate images to upload an image, crop it and save that version to the remote server.

One of the numerous advantages brought about by the explosion of jQuery and other JavaScript libraries is the ease with which you can create interactive tools for your site. When combined with server-side technologies such as PHP, this puts a serious amount of power at your finger tips. [...] Sure, there are plugins out there that you can use to do this; but this article aims to show you what's behind the process. You can download the source files for reference.

They walk you through the little bit of setup you'll need before things will be working and then move right into the upload form and PHP handling that goes with it. The Javascript that goes with it is all home-grown (not a plugin) and cleverly uses a DIV to simulate the bounding box for the crop.

]]>Tue, 05 Apr 2011 12:02:30 -0500http://www.phpdeveloper.org/news/15283http://www.phpdeveloper.org/news/15283
On CodeForest.net there's a new tutorial that merges the power of PHP and the popular jQuery javascript library to create an image cropping tool you can use on your site.

So, your client uploaded the image into your newly, freshly developed CMS and then called you to yell about distorted image, or image that just does not look good? That is a well known scenario. Let me explain a bit what we will achieve today. When your client uploads an image, he is taken to an Image edit area where he sees uploaded image and a smaller preview window. He just needs to drag on the larger image to select crop area and press submit. After that you crop the image using PHP GD functionality and save the new image somewhere on disk.

Their focus is mainly on the image editing part using the ImageAreaSelect jQuery plugin to help with the actual crop size selection. After the selection is finished, though, those values get sent back to a PHP script (via a form) and the resulting image is cropped and saved with help from the GD functionality of PHP.

]]>Thu, 14 Oct 2010 13:49:52 -0500http://www.phpdeveloper.org/news/11170http://www.phpdeveloper.org/news/11170
Asvin Balloo has posted a tutorial that shows how to combine the YUI libraries with PHP to create a simple image cropper.

This post will show you how to build an AJAX crop image tool using the image cropper control from YUI library and PHP. The ImageCropper Control from the YUI library gives you an interactive interface for getting the dimensions to crop an image and using these dimensions in PHP, we can do some cropping.

The script takes in an upload, shows it in the browser for cropping and once altered, pushes the altered image back out as a download. Full code is included as well as a demo of the final result and a sample file to get you started.

]]>Wed, 08 Oct 2008 12:09:21 -0500http://www.phpdeveloper.org/news/7320http://www.phpdeveloper.org/news/7320
The Bakery has a new helper posted today for those working with images in their applications that need to resize and cache them easily.

This helper resizes an image on the fly and places it in an image cache directory for later use. Make sure your imagecache directory is writable. Future editions could include a cropping function.

The full code of the class is provided in both a cut and paste-able format and for download. There's an example of the sample usage included as well.