dtstnjl898781429 2015-08-17 12:06
浏览 287
已采纳

如何在php imagemagick中指定所有四个角坐标的叠加图像

I am a beginner in Imagemagick / Imagick, so please bear with me. My issue looks rather simple, but I could not find a solution, or any help anywhere. Please take a look at the image below - I am trying to create an image, by specifying all four corners coordinates in pixels.

I looked at Affine Distortion but that function is too complicated for me, sometimes takes a while to be executed, and when it works - the results are very unpredictable (image rotation is wrong, there are parts of the image removed or misplaced, etc.) So if anyhow possible, I would not like to have to use Affine distortion.

Of course, if it is not possible to just specify each corner coordinates, a help in which direction I should be going is greatly appreciated. I would like to use Imagick, but if this is maybe better to do with GD or similar, I am open for that.

1]

  • 写回答

1条回答 默认 最新

  • dongqiaozhe5070 2015-08-17 13:31
    关注

    Without seeing source images, and what the expected result would be, I would assume you are attempting Perspective distortion. Meaning you want to take an image, and transform the MBR coordinates to a predefined set of points.

    If I'm given a 400x400 checkerboard image, and want to distort it to the points listed above, the following ImageMagick command would work.

    convert -size 400x400 pattern:checkerboard \
            -virtual-pixel transparent \
            -mattecolor transparent \
            -distort Perspective '0,0 50,153  400,0 240,40 0,400 315,355 400,400 336,156' \
            distorted_checkerboard.png
    

    distorted_checkerboard.png

    The -distort Perspective '... point matrix ...' reads as the following

      Origin Point  => Finial Point
        0,  0       =>  50,153       (top left)
      400,  0       => 240, 40       (top right)
        0,400       => 315,255       (bottom left)
      400,400       => 336,155       (bottom right)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算