Imposible to rotate an image in Joomla core
Rotating an image in Joomla
Labels |
Added:
?
|
And if you're looking for a PHP API see https://api.joomla.org/cms-3/classes/Joomla.CMS.Image.Image.html (don't mind the deprecation notices, those actually need to go away and some refactoring needs to happen, I have another issue on the topic somewhere).
If you're looking for a UI integration for this, the media manager in 4.0 supports it.
Is there anything you missing after this knowledge?
Yes thank you for trying to help, maybe its very simple and obviuos but I cant find there I need to insert this code to make it work in Joomla 3.9?
For example If I need to Watermark all the images in articles?
watermark(\Joomla\Image\Image $watermark, integer $transparency = 50, integer $bottomMargin, integer $rightMargin) : \Joomla\Image\Image
Do I need to insert this code in protostar template, in what file of this template or somethere else?
@Milglius get this https://github.com/dgrammatiko/imageUploaderHelper
Make all the alterations you need and then all your files will be watermarked or whatever you choose to do there after the upload process.
@Milglius try the JCE Editor Component. It comes with a very handy image editor that allows you to rotate, resize and crop your images.
Hope this helps.
C
@Milglius try the JCE Editor Component. It comes with a very handy image editor that allows you to rotate, resize and crop your images.
Hope this helps.
C
The plugin @dgrammatiko linked to demonstrates use of the Image API.
so api works only in plugin you cant just paste watermark(\Joomla\Image\Image $watermark, integer $transparency = 50, integer $bottomMargin, integer $rightMargin) : \Joomla\Image\Image
in the template ?
You can't paste that line as is anywhere, the API documentation doesn't give code examples but some basic documentation of what the method does and its signature which contains what the method expects to receive and what will be returned at the end of it. If you need a practical example, this is one:
use Joomla\CMS\Image\Image;
$imagePath = '/path/to/image.jpg';
$watermarkedImagePath = '/path/to/image-watermark.jpg';
// Get the image type from file properties so we save things correctly
$imageType = Image::getImageFileProperties($imagePath)->type;
// Load image to be watermarked
$image = new Image;
$image->loadFile($imagePath);
// Load image to use as watermark
$watermarkImage = new Image;
$watermarkImage->loadFile('/path/to/watermark.jpg');
// Customize to suit your needs
$transparency = 50;
$bottomMargin = 10;
$rightMargin = 10;
// Apply watermark to image
$image->watermark($watermarkImage, $transparency, $bottomMargin, $rightMargin);
// Save to filesystem
$image->toFile($watermarkedImagePath, $imageType);
This should be done in a plugin listening to a save event, not in your template. The Image API is meant to edit images then save them back into the filesystem, it will be painfully inefficient if you try to watermark an image in your template each time the page is displayed.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-02-15 15:16:39 |
Closed_By | ⇒ | mbabker |
At this point this issue is turning into a user support request, which isn't what this platform is used for. If you need further assistance, please use the forums at https://forum.joomla.org.
Given there is an API in Joomla for plugins to process images, the media manager in 4.0 will have more image editing capabilities, and there are extensions for 3.x to do this type of thing, there isn't any feature request here that isn't already fulfilled either.
Thank you for information
No, it's not impossible to rotate an image in Joomla.
Please do some CSS research: https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate
Unless your template has something like this, which is highly unlikely: