CodeIgniter/PHP/GD2 Görüntü İşleme yukarı oynuyor

0 Cevap php

(1500x1125 küçültüldü) ile yazdırmak için bir 'tam' kopya online görüntülemek için bir 'web' copy (henüz kodlu değil), ve nihayet küçük - Ben gidiyorum, bir web sitesi bir kullanıcının yükledi görüntü alır ve üç kopya yapar var.

Yani burada kod - _imageformat () CI yükle Sınıfı'ndan (I doğru olduğu teyit ettik) parametreleri geçirilir:

function _imageformat($fullpath, $shortpath, $width, $height)

{ // We now format the image.

// First, we check if it is landscape or portrait if ($width >= $height) // It's landscape (or square) { // Now create the full printing image $fullimage = $this->_resize('l', $fullpath, $shortpath, $width, $height); } else // It's portrait { // Now create the full printing image $fullimage = $this->_resize('p', $fullpath, $shortpath, $width, $height); }

}

function _resize($type, $fullpath, $shortpath, $width, $height) { // Set up the default Image Manipulation config options $config['image_library'] = 'gd2'; $config['source_image'] = $fullpath; $config['maintain_ratio'] = TRUE;

// Shave the '.jpg' from the end to append some nice suffixes we'll use
$newimage = substr($fullpath, 0, -4).'_full'.".jpg";

$config['new_image'] = $newimage;

if ($type == 'l') // If it's landscape
{
 $config['width'] = 1500;
 $config['height'] = 1125;
}
else if ($type == 'p') // If it's portrait
{
 $config['width'] = 1125;
 $config['height'] = 1500;   
}

// Load the image library with the specified parameters, and resize the image!  
$this->load->library('image_lib', $config); 
$this->image_lib->resize();

// Create a thumbnail from the full image
$config['source_image']  = $newimage;
$config['new_image']  = substr($fullpath, 0, -9)."_thumb".".jpg";
$config['maintain_ratio']  = TRUE;
$config['width']    = 150;
$config['height']   = 150;

$this->load->library('image_lib', $config); 

$this->image_lib->resize();

return $newimage;

}

Orijinal yüklenen dosya (biz resim.jpg arayacağım), (image_full.jpg adlı) resized dosyası ve küçük resim (adlandırılmış image_thumb.jpg - What SHOULD happen: Benim yüklenenler klasöründe, üç görüntüleri vardır .)

Orijinal yüklenen dosya (resim.jpg) ve resized dosya (image_full.jpg) - What DOES happen: Benim yüklenenler klasöründe, sadece TWO görüntüleri vardır. Küçük resim yok hiç oluşturulur.

What's interesting, however, ** is that if I place the code for the Thumbnail creation first, bu küçük resim oluşturur, ancak ** NOT _full (resized) görüntü.

Bu yüzden şimdiye kadar iki kez $this->image_lib->resize() aday olmayacağını bana görünür. Neden değil? Ben yapıyorum, ya da belirgin bir şey cevapsız bazı amatör hata mı?! : P

Teşekkürler!

Kriko

Edit: Evet, ben iki kere image_lib kütüphane yükleme biliyorum işaret olmalıdır. Ben bu ona yeni parametreleri geçen tek yoluydu fathomed. Ben de tekrar orada kütüphane yüklü olan $this->_thumbnail() çağırarak, tam resim boyutlandırma sonra çalıştı. Ama yine aynı sorun oluştu.

Hala şans - Edit 2: Ben de kullanarak $this->image_lib->clear() denedim.

0 Cevap