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 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测