开发者

Image copy, create and rename with PHP?

I need to create a function that, given a target folder w开发者_运维问答ill...

1) Check to see if a file named myImage.png exists in the target folder and creates a copy of it called myImage-default.png

2)Checks to see if a file named "myImage-trans.png" exists in the target folder (creates it if not), makes a copy of it and saves it as myImage.png (myImage-trans.png should be a 1x1 pixel transparent png)

How difficult might this be and what PHP methods would you use?

  • All images will reside in the root of the target folder. No subfolders involved.


Shouldn't be too bad.

Here are some PHP functions that will get you started:

filexists - Check if that file exists

imagecreate - Create an image if that image doesn't already exist

imagepng - Output a PNG file with your newly created image

imagecopy - Copy a portion of an image

copy - Copy a file

rename - rename a file


You're looking at basic file system functions. Take a look here for a list of available functions!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜