dtjxhf595733 2017-06-04 00:46
浏览 67
已采纳

如何在不使用exec功能的情况下制作平铺图像帧?

Original image: Original image Here what i need: Here what i need It should be created from this small tile: It should be created from this small tile

A lot of people suggest to use ImageMagick solution (it using php exec function) - http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=21867:

convert frame_template.gif \
-tile blackthin_top.gif -draw 'color 1,0 floodfill' -rotate 90 \
-tile blackthin_btm.gif -draw 'color 1,0 floodfill' -rotate 90 \
-tile blackthin_top.gif -draw 'color 1,0 floodfill' -rotate 90 \
-tile blackthin_btm.gif -draw 'color 1,0 floodfill' -rotate 90 \
-gravity center thumbnail.gif -composite frame_filled.gif

or

PICFrame solution (it using php exec function) - http://www.fmwconcepts.com/imagemagick/picframe/index.php:

picframe [-f frameid] [-m mattesize] [-c mattecolor] [-b bordersize] [-s shade] [-a adjust] [-o opacity ] [-d distance] infile outfile

PHP imagick has great ability to create color borders with:

$imagick = new \Imagick('image.jpg');
$imagick->scaleImage(300, 300, false);

// Create frame placeholder
$imagick->frameimage( 'red','30','30', 30, 0);

// Flood fill with color
$imagick->floodFillPaintImage('green', 10, '#6e0000',0, 0,false
);

header("Content-Type: image/jpg");
echo $imagick->getImageBlob();

But PHP imagick can't use your own image tile to create frame, only solid colors. Here is very related question - How to flood fill the frame with a pattern image using imagick php class?

Another good solution from - https://stackoverflow.com/a/28778953/2337706 but it creates image from big PNG frames and you should know correct image size.

I know that i can create it with php GD - http://php.net/manual/en/ref.image.php but i don't know correct way how implement it this way.

  • 写回答

1条回答 默认 最新

  • douxi4287 2017-06-04 03:03
    关注

    In ImageMagick, you could just do something simple like this:

    convert a1Wit.jpg -mattecolor black -frame 10x10+3+3 -gravity west -chop 3x0 -bordercolor gold -border 3 frame_result.jpg
    

    enter image description here

    These commands should be easy enough to translate into Imagick. See http://us3.php.net/manual/en/imagick.frameimage.php and http://us3.php.net/manual/en/imagick.chopimage.php and http://us3.php.net/manual/en/imagick.borderimage.php

    Or simply:

    convert a1Wit.jpg -bordercolor black -border 7 -bordercolor "gray(35%)" -border 3 -bordercolor "#D0A456" -border 3 frame_result2.jpg
    

    enter image description here

    Or

    convert a1Wit.jpg -mattecolor "gray(30%)" -frame 13x13+5+5 -gravity northwest -shave 5x5 -bordercolor "#D0A456" -border 3 frame_result3.jpg
    

    enter image description here

    Or

    convert a1Wit.jpg -mattecolor "gray(30%)" -frame 13x13+5+5 -gravity northwest -bordercolor "#D0A456" -border 3 frame_result4.jpg
    

    enter image description here

    Adjust the color thicknesses as desired

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化