Skip to content

Instantly share code, notes, and snippets.

@ronnyandre
Created January 10, 2014 13:04
Show Gist options
  • Save ronnyandre/8351604 to your computer and use it in GitHub Desktop.
Save ronnyandre/8351604 to your computer and use it in GitHub Desktop.
Resize PDF with WP_Image_Editor to square JPEG thumbnail.
<?php
// Load PDF
$img = wp_get_image_editor( 'my/temp/uploads/path/mypdf.pdf' );
// Resize PDF
$img->resize( 50, 50, TRUE );
// Generate filename
$filename = $img->generate_filename( 'thumb', 'wp/wp-content/uploads/thumbs/', 'jpg' );
// Save
$img->save( $filename, 'image/jpeg' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment