Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

vips_similarity syntax error? #1041

Closed
wyatt121 opened this issue Jul 23, 2018 · 5 comments
Closed

vips_similarity syntax error? #1041

wyatt121 opened this issue Jul 23, 2018 · 5 comments
Labels

Comments

@wyatt121
Copy link

Hi John,

I'm trying to rotate my design a few degrees before overlaying on my base t-shirt. I can't seem to get the syntax correct for vips_similarity. Are any of these 3 lines correct?

$overlay = Vips\Image::newFromFile($design_image);

$overlay = Vips\Image::vips_similarity($overlay, $overlay, 15);  
$overlay = $overlay->vips_similarity($overlay, 15);   
$overlay = $overlay->vips_similarity(15);   

I keep getting this error:

PHP Fatal error: Uncaught Jcupitt\Vips\Exception: VipsOperation: class "vips_similarity" not found
in /var/www/html/build/vendor/jcupitt/vips/src/Image.php:664

Any help is much appreciated.

Regards,

Wyatt

@jcupitt
Copy link
Member

jcupitt commented Jul 23, 2018

Hello, angle and scale are optional arguments, so you have to name them. For example:

# no scale, only rotate
$overlay = $overlay->vips_similarity($overlay, ["angle" => 15]);

@wyatt121
Copy link
Author

wyatt121 commented Jul 23, 2018 via email

@jcupitt
Copy link
Member

jcupitt commented Jul 23, 2018

Sorry, copy/paste error. Try:

# no scale, only rotate
$overlay = $overlay->similarity(["angle" => 15]);

@wyatt121
Copy link
Author

Hi John,

This worked great! I'm now able to finely tune the angular rotation of the design placed on each apparel piece so they look 100% natural and perfect.

As for now, I just overlay graphics on flat apparel in 1 plane, but will your library allow me "transform" a graphic before I overlay it on an apparel piece so it looks natural when placed on a person/ model turning sideways?

Placeit.net has built an entire mockup service around this functionality...
See here: https://placeit.net/c/mockups/?f_types=image&f_devices=T-Shirt&f_tags=Selfie&is_list=true

Rock on John! I hope I can help you as much in the future, as you have helped me.

Regards,

Wyatt

@jcupitt
Copy link
Member

jcupitt commented Jul 24, 2018

I like the mockup generator.

Yes, libvips can do that, it has a warp function. You need to model the share you want to fit though, and that takes some maths and a bit of effort.

@lovell lovell closed this as completed Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants