Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to use flipHorizontally method in this library #37

Open
rashidaghadiinfotech opened this issue Dec 6, 2022 · 4 comments
Open

How to use flipHorizontally method in this library #37

rashidaghadiinfotech opened this issue Dec 6, 2022 · 4 comments

Comments

@rashidaghadiinfotech
Copy link

rashidaghadiinfotech commented Dec 6, 2022

Hello there,

Anyone knows how to use flipHorizontally() method in this library.
I referred this docs https://imagine.readthedocs.io/en/stable/index.html but didn't found anything to flip the SVG image.

I simply want to flip the image

$imagine = new Imagine();
  $image = $imagine->open($svg_file);
  $image->resize(new Box($determine_width, $determine_height));
  
  $color_code = $option_list['sic_color_code'] ? $option_list['sic_color_code'] : '#000000';
  $image->effects()->colorize($image->palette()->color($color_code));
  
  $image->flipHorizontally();
  
  $image->save($file_path);

Error is : Uncaught Imagine\Exception\NotSupportedException: This method is not implemented in.........

Any idea what I am missing here?

@ausi you helped me on colorize stuff earlier and it was a great method. Can you please help me here too?
Your help will be highly appreciated.

Update:
I also used following code but same error

$transformation = new Transformation();
$transformation->flipVertically();
$transformation->apply( $imagine->open($file_path) )->save($file_path_2);
@ausi
Copy link
Member

ausi commented Dec 6, 2022

Several image methods are not yet implemented in this library: paste(), rotate(), flipHorizontally(), flipVertically(), draw(), applyMask(), fill(), mask(), histogram(), getColorAt(), layers(), interlace(), profile().

So for flipHorizontally() and flipVertically() to work they have to be implemented first, e.g. by a pull request to this library.

@rashidaghadiinfotech
Copy link
Author

@ausi
So there is no way to flip an svg image for a temporary solution?

@rojtjo
Copy link

rojtjo commented Dec 6, 2022

Depending on your use case you might be able to get away by adding a style attribute:

Horizontal:

<svg style="transform: scale(-1,1)"></svg>

Vertical:

<svg style="transform: scale(1,-1)"></svg>

@rashidaghadiinfotech
Copy link
Author

@rojtjo @ausi

I tried that transform but problem is it do not work in some printing softwares like inkspace or Flexi (from thinksai)

It ignores my css though.
It also avoid the method I used for colorize. (In web browsers it works though)
$image->effects()->colorize($image->palette()->color($color_code));

To fix this, I added fill to the path forcefully somehow.
But adding transform is not working at all.

Any thoughts or ideas ?

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants