P
P
Pavel2019-10-16 13:25:43
Joomla
Pavel, 2019-10-16 13:25:43

How to generate Joomla JImage thumbnails?

In the content output category ( com_content\category) I go through a foreach loop

<?php foreach ($this->lead_items as &$item) :
$pathToImage = $item->jcfields[5]->rawvalue; //получаю изображение из дополнительного поля
 ?>
<?php endforeach; ?>

Next, I want to resize the $pathToImage image and display a thumbnail
$image = new JImage( $pathToImage );
$image->resize(100, 100, false, JImage::SCALE_INSIDE );
$image->toFile( $path, $type, array( 'quality'=>70 ) );

This code gives krakozyabra)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton R., 2019-10-16
@anton_reut

This piece of code is painfully similar to imageMagic:

$image = new JImage( $pathToImage );
$image->resize(100, 100, false, JImage::SCALE_INSIDE );
$image->toFile( $path, $type, array( 'quality'=>70 ) );

My example of resizing and saving an image using the imageMagic library:
$image = new Imagick('image.jpg');
$image->resizeImage(400, 300, Imagick::FILTER_LANCZOS, 1);
$image->writeImage('image_new.jpg');
$image->destroy();

You get krakozyabry apparently due to the fact that you are trying to display a picture on the screen and not write it to a file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question