Skip to content

Instantly share code, notes, and snippets.

@getsource
Created July 27, 2012 20:52
Show Gist options
  • Save getsource/3190423 to your computer and use it in GitHub Desktop.
Save getsource/3190423 to your computer and use it in GitHub Desktop.
GD in WordPress
# GD in WordPress
From: http://www.php.net/manual/en/ref.image.php
## Functions Used:
* getimagesize
* imagealphablending
* imageantialias
* imagecolorstotal
* imagecopy
* imagecopyresampled
* imagecreatefromgif
* imagecreatefromjpeg
* imagecreatefrompng
* imagecreatefromstring
* imagecreatetruecolor
* imagedestroy
* imagegif
* imageistruecolor
* imagejpeg
* imagepng
* imagerotate
* imagesavealpha
* imagesx
* imagesy
* imagetruecolortopalette
* imagetypes
* iptcparse
## Details:
* getimagesize
(svn :21358M ) macNull:wpbranch mike$ ack getimagesize
wp-admin/custom-header.php
699: list( $width, $height, $type, $attr ) = getimagesize( $file );
872: $size = @getimagesize( $cropped );
wp-admin/includes/image.php
56: $size = @getimagesize( $src_file );
61: $size = @getimagesize( $src );
117: $imagesize = getimagesize( $file );
227: list( , , $sourceImageType ) = getimagesize( $file );
249: getimagesize( $file, $info );
343: $size = @getimagesize($path);
357: $info = @getimagesize($path);
wp-includes/deprecated.php
1980: $imagesize = getimagesize($src_file);
wp-includes/functions.php
1694: * Currently this function only supports validating images known to getimagesize().
1716: if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) {
1719: $imgstats = @getimagesize( $file );
1721: // If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME
1723: // This is a simplified array of MIMEs that getimagesize() can detect and their extensions
1725: $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
wp-includes/media.php
155: if ( ($thumb_file = wp_get_attachment_thumb_file($id)) && $info = getimagesize($thumb_file) ) {
423: $size = @getimagesize( $file );
499: if ( !is_wp_error($resized_file) && $resized_file && $info = getimagesize($resized_file) ) {
624: @list($width, $height) = getimagesize($src_file);
* imagealphablending
(svn :21358M ) macNull:wpbranch mike$ ack imagealphablending
wp-admin/includes/image.php
399: if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
400: imagealphablending($image, false);
wp-includes/media.php
1026: if ( is_resource($img) && function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
1027: imagealphablending($img, false);
* imageantialias
(svn :21358M ) macNull:wpbranch mike$ ack imageantialias
wp-admin/includes/image.php
76: if ( function_exists( 'imageantialias' ) )
77: imageantialias( $dst, true );
* imagecolorstotal
(svn :21358M ) macNull:wpbranch mike$ ack imagecolorstotal
wp-includes/media.php
439: imagetruecolortopalette( $newimage, false, imagecolorstotal( $image ) );
* imagecopy
(svn :21358M ) macNull:wpbranch mike$ ack imagecopy
wp-admin/includes/image-edit.php
273: if ( imagecopy($dst, $img, 0, 0, $x, $y, $w, $h) ) {
* imagecopyresampled
(svn :21358M ) macNull:wpbranch mike$ ack imagecopyresampled
wp-admin/includes/image-edit.php
262: if ( imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh) ) {
372: imagecopyresampled( $preview, $img, 0, 0, 0, 0, $w2, $h2, $w, $h );
481: if ( imagecopyresampled( $dst, $img, 0, 0, 0, 0, $fwidth, $fheight, $sX, $sY ) ) {
wp-admin/includes/image.php
79: imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );
wp-includes/media.php
323: * Retrieve calculated resized dimensions for use in imagecopyresampled().
338: * @return bool|array False on failure. Returned array matches parameters for imagecopyresampled() PHP function.
389: // the return array matches the parameters to imagecopyresampled()
435: imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
* imagecreatefromgif
(svn :21358M ) macNull:wpbranch mike$ ack imagecreatefromgif
wp-admin/includes/image.php
391: $image = imagecreatefromgif($filepath);
wp-includes/media.php
1009: return function_exists('imagecreatefromgif');
* imagecreatefromjpeg
(svn :21358M ) macNull:wpbranch mike$ ack imagecreatefromjpeg
wp-admin/includes/image.php
385: $image = imagecreatefromjpeg($filepath);
wp-includes/media.php
1005: return function_exists('imagecreatefromjpeg');
* imagecreatefrompng
(svn :21358M ) macNull:wpbranch mike$ ack imagecreatefrompng
wp-admin/includes/image.php
388: $image = imagecreatefrompng($filepath);
wp-includes/media.php
1007: return function_exists('imagecreatefrompng');
* imagecreatefromstring
(svn :21358M ) macNull:wpbranch mike$ ack imagecreatefromstring
wp-includes/media.php
253: if ( ! function_exists('imagecreatefromstring') )
258: $image = imagecreatefromstring( file_get_contents( $file ) );
* imagecreatetruecolor
(svn :21358M ) macNull:wpbranch mike$ ack imagecreatetruecolor
wp-includes/media.php
1025: $img = imagecreatetruecolor($width, $height);
* imagedestroy
(svn :21358M ) macNull:wpbranch mike$ ack imagedestroy
wp-admin/includes/image-edit.php
245: imagedestroy($img);
263: imagedestroy($img);
274: imagedestroy($img);
375: imagedestroy($preview);
376: imagedestroy($img);
482: imagedestroy($img);
623: imagedestroy($img);
wp-admin/includes/image.php
81: imagedestroy( $src ); // Free up memory
wp-includes/media.php
442: imagedestroy( $image );
471: imagedestroy( $newimage );
* imagegif
(svn :21358M ) macNull:wpbranch mike$ ack imagegif
wp-admin/includes/image-edit.php
212: return imagegif($image);
230: return imagegif($image, $filename);
wp-includes/media.php
458: if ( !imagegif( $newimage, $destfilename ) )
* imageistruecolor
(svn :21358M ) macNull:wpbranch mike$ ack imageistruecolor
wp-includes/media.php
438: if ( IMAGETYPE_PNG == $orig_type && function_exists('imageistruecolor') && !imageistruecolor( $image ) )
* imagejpeg
(svn :21358M ) macNull:wpbranch mike$ ack imagejpeg
wp-admin/includes/image-edit.php
206: return imagejpeg($image, null, 90);
226: return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) );
wp-admin/includes/image.php
97: elseif ( imagejpeg( $dst, $dst_file, apply_filters( 'jpeg_quality', 90, 'wp_crop_image' ) ) )
wp-includes/media.php
467: if ( !imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) )
* imagepng
(svn :21358M ) macNull:wpbranch mike$ ack imagepng
wp-admin/includes/image-edit.php
209: return imagepng($image);
228: return imagepng($image, $filename);
wp-admin/includes/image.php
95: if ( 'image/png' == $image_type && imagepng( $dst, $dst_file ) )
wp-includes/media.php
461: if ( !imagepng( $newimage, $destfilename ) )
* imagerotate
(svn :21358M ) macNull:wpbranch mike$ ack imagerotate
wp-admin/includes/image-edit.php
42: // On some setups GD library does not provide imagerotate() - Ticket #11536
43: if ( function_exists('imagerotate') ) { ?>
47: $note_gdlib = esc_attr__('Image rotation is not supported by your web host (function imagerotate() is missing)');
242: if ( function_exists('imagerotate') ) {
243: $rotated = imagerotate($img, $angle, 0);
* imagesavealpha
(svn :21358M ) macNull:wpbranch mike$ ack imagesavealpha
wp-admin/includes/image.php
399: if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
401: imagesavealpha($image, true);
wp-includes/media.php
1026: if ( is_resource($img) && function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
1028: imagesavealpha($img, true);
* imagesx
(svn :21358M ) macNull:wpbranch mike$ ack imagesx
wp-admin/includes/image-edit.php
253: $w = imagesx($img);
343: $scale = 1 / _image_get_preview_ratio( imagesx($img), imagesy($img) ); // discard preview scaling
365: $w = imagesx($img);
473: $sX = imagesx($img);
559: $meta['width'] = imagesx($img);
* imagesy
(svn :21358M ) macNull:wpbranch mike$ ack imagesy
wp-admin/includes/image-edit.php
254: $h = imagesy($img);
343: $scale = 1 / _image_get_preview_ratio( imagesx($img), imagesy($img) ); // discard preview scaling
366: $h = imagesy($img);
474: $sY = imagesy($img);
560: $meta['height'] = imagesy($img);
* imagetruecolortopalette
(svn :21358M ) macNull:wpbranch mike$ ack imagetruecolortopalette
wp-includes/media.php
439: imagetruecolortopalette( $newimage, false, imagecolorstotal( $image ) );
* imagetypes
(svn :21358M ) macNull:wpbranch mike$ ack imagetypes
wp-includes/media.php
993: if ( function_exists('imagetypes') ) {
996: return (imagetypes() & IMG_JPG) != 0;
998: return (imagetypes() & IMG_PNG) != 0;
1000: return (imagetypes() & IMG_GIF) != 0;
* iptcparse
(svn :21358M ) macNull:wpbranch mike$ ack iptcparse
wp-admin/includes/image.php
248: if ( is_callable( 'iptcparse' ) ) {
252: $iptc = iptcparse( $info['APP13'] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment