Jaxel
Well-known member
This is the current code:
The problem is getimagesize wont work unless fURL is enabled. $thumb is the location of the thumbnail. Basically, all I need to do is take $thumb, store it in a temporary file... create the thumbnail image, then delete the temporary file... How would I do all this using Zend_Http?
This is a brief summary of how the code above works...
1 - it gets the thumbnail URL which is stored in $thumb...
2 - gets thumb information (IMAGETYPE constant) from thumbnail URL using getImageSize
3 - creates image from thumbnail URL and IMAGETYPE using createFromFile
4 - takes newly created image and thumb-crop-centers the image to 160x90px (within the IF)
Steps 2 and 3, dont work with my current code unless fURL is enabled. Without fURL, you can't run processes on external entities hosted on different services. So I can't run "getImageSize" (step 2), and I cant run "createFromFile" (step 3).
So what I need to do is add two new steps:
1.5 - store image from thumbnail URL into temporary file
5 - delete temporary file
How would I do that? There is no "upload" involved.
Code:
public function buildThumb($mediaID, $thumb)
{
$targetLoc = XenForo_Helper_File::getExternalDataPath().'/media/'.$mediaID.'.jpg';
$imageInfo = getimagesize($thumb);
if ($image = XenForo_Image_Abstract::createFromFile($thumb, $imageInfo[2]))
{
$ratio = 160/90;
$width = $image->getWidth();
$height = $image->getHeight();
if ($width/$height > $ratio)
{
$image->thumbnail($width, '90');
}
else
{
$image->thumbnail('160', $height);
}
$width = $image->getWidth();
$height = $image->getHeight();
$offWidth = ($width - 160) / 2;
$offHeight = ($height - 90) / 2;
$image->crop($offWidth, $offHeight, '160', '90');
$image->output(IMAGETYPE_JPEG, $targetLoc);
}
}
The problem is getimagesize wont work unless fURL is enabled. $thumb is the location of the thumbnail. Basically, all I need to do is take $thumb, store it in a temporary file... create the thumbnail image, then delete the temporary file... How would I do all this using Zend_Http?
This is a brief summary of how the code above works...
1 - it gets the thumbnail URL which is stored in $thumb...
2 - gets thumb information (IMAGETYPE constant) from thumbnail URL using getImageSize
3 - creates image from thumbnail URL and IMAGETYPE using createFromFile
4 - takes newly created image and thumb-crop-centers the image to 160x90px (within the IF)
Steps 2 and 3, dont work with my current code unless fURL is enabled. Without fURL, you can't run processes on external entities hosted on different services. So I can't run "getImageSize" (step 2), and I cant run "createFromFile" (step 3).
So what I need to do is add two new steps:
1.5 - store image from thumbnail URL into temporary file
5 - delete temporary file
How would I do that? There is no "upload" involved.