简体   繁体   English

如何将图像放在图像上并调整大小并拖动

[英]how can I put image on image and resize and drag it

I want to implement customize mug design with PHP, by default there is glass image is there, then user can upload her/his image , the the image will put on the glass, user change resize and move it, like below picture 我想用PHP实现自定义杯子设计,默认情况下有玻璃图像,然后用户可以上传她/他的图像,该图像将放在玻璃上,用户更改大小并移动它,如下图所示

在此处输入图片说明

how can I implement it , any idea? 我如何实现它,有什么想法吗? any help about some jquery libraries .... 关于一些jQuery库的任何帮助...。

For image dragging & resizing, you can use the .draggable() & .resizable() functions in jQuery UI. 对于图像的拖动和调整大小,可以在jQuery UI中使用.draggable().resizable()函数。

This is fully customized and you will be able to reach your goal easily. 这是完全定制的,您将可以轻松实现目标。

For image merging, you can use the code from this subject : 对于图像合并,您可以使用以下主题的代码:

<?php
    $dest = imagecreatefrompng('vinyl.png');
    $src = imagecreatefromjpeg('cover2.jpg');

    imagealphablending($dest, false);
    imagesavealpha($dest, true);

    imagecopymerge($dest, $src, 10, 9, 0, 0, 181, 180, 100); //have to play with these numbers for it to work for you, etc.

    header('Content-Type: image/png');
    imagepng($dest);

    imagedestroy($dest);
    imagedestroy($src);

?> ?>

And if you use PHP, also have a look to ImageMagick 如果您使用PHP,也可以看看ImageMagick

Use fabric.js for All your need , It uses canvas under the hood 使用fabric.js满足您的所有需求,它在后台使用画布

  • there you can set your image on cup 在那里,您可以将图像设置在杯子上
  • resize it , drag it 调整大小,拖动
  • and save image in dataurl then to any jpeg or png 并将图像保存在dataurl中,然后保存为任何jpeg或png

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM