利用php给图片添加文字水印-面向对象与面临过程俩种方法的实现
利用php给图片添加文字水印--面向对象与面向过程俩种方法的实现
1: 面向过程的编写方法
<span style="color: #008000;">//</span><span style="color: #008000;">指定图片路径</span><span style="color: #800080;">$src</span> = '001.png'<span style="color: #000000;">;</span><span style="color: #008000;">//</span><span style="color: #008000;">获取图片信息</span><span style="color: #800080;">$info</span> = <span style="color: #008080;">getimagesize</span>(<span style="color: #800080;">$src</span><span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">获取图片扩展名</span><span style="color: #800080;">$type</span> = image_type_to_extension(<span style="color: #800080;">$info</span>[2],<span style="color: #0000ff;">false</span><span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">动态的把图片导入内存中</span><span style="color: #800080;">$fun</span> = "imagecreatefrom{<span style="color: #800080;">$type</span>}"<span style="color: #000000;">;</span><span style="color: #800080;">$image</span> = <span style="color: #800080;">$fun</span>('001.png'<span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">指定字体颜色</span><span style="color: #800080;">$col</span> = imagecolorallocatealpha(<span style="color: #800080;">$image</span>,255,255,255,50<span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">指定字体内容</span><span style="color: #800080;">$content</span> = 'helloworld'<span style="color: #000000;">;</span><span style="color: #008000;">//</span><span style="color: #008000;">给图片添加文字</span>imagestring(<span style="color: #800080;">$image</span>,5,20,30,<span style="color: #800080;">$content</span>,<span style="color: #800080;">$col</span><span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">指定输入类型</span><span style="color: #008080;">header</span>('Content-type:'.<span style="color: #800080;">$info</span>['mime'<span style="color: #000000;">]);</span><span style="color: #008000;">//</span><span style="color: #008000;">动态的输出图片到浏览器中</span><span style="color: #800080;">$func</span> = "image{<span style="color: #800080;">$type</span>}"<span style="color: #000000;">;</span><span style="color: #800080;">$func</span>(<span style="color: #800080;">$image</span><span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">销毁图片</span>imagedestroy(<span style="color: #800080;">$image</span>);
2:面向对象的实现方法
<span style="color: #0000ff;">class</span><span style="color: #000000;"> Image_class { </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$image</span><span style="color: #000000;">; </span><span style="color: #0000ff;">private</span> <span style="color: #800080;">$info</span><span style="color: #000000;">; </span><span style="color: #008000;">/*</span><span style="color: #008000;">* * @param $src:图片路径 * 加载图片到内存中 </span><span style="color: #008000;">*/</span> <span style="color: #0000ff;">function</span> __construct(<span style="color: #800080;">$src</span><span style="color: #000000;">){ </span><span style="color: #800080;">$info</span> = <span style="color: #008080;">getimagesize</span>(<span style="color: #800080;">$src</span><span style="color: #000000;">); </span><span style="color: #800080;">$type</span> = image_type_to_extension(<span style="color: #800080;">$info</span>[2],<span style="color: #0000ff;">false</span><span style="color: #000000;">); </span><span style="color: #800080;">$this</span> -> info =<span style="color: #800080;">$info</span><span style="color: #000000;">; </span><span style="color: #800080;">$this</span>->info['type'] = <span style="color: #800080;">$type</span><span style="color: #000000;">; </span><span style="color: #800080;">$fun</span> = "imagecreatefrom" .<span style="color: #800080;">$type</span><span style="color: #000000;">; </span><span style="color: #800080;">$this</span> -> image = <span style="color: #800080;">$fun</span>(<span style="color: #800080;">$src</span><span style="color: #000000;">); } </span><span style="color: #008000;">/*</span><span style="color: #008000;">* * @param $fontsize: 字体大小 * @param $x: 字体在图片中的x位置 * @param $y: 字体在图片中的y位置 * @param $color: 字体的颜色是一个包含rgba的数组 * @param $text: 想要添加的内容 * 操作内存中的图片,给图片添加文字水印 </span><span style="color: #008000;">*/</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> fontMark(<span style="color: #800080;">$fontsize</span>,<span style="color: #800080;">$x</span>,<span style="color: #800080;">$y</span>,<span style="color: #800080;">$color</span>,<span style="color: #800080;">$text</span><span style="color: #000000;">){ </span><span style="color: #800080;">$col</span> = imagecolorallocatealpha(<span style="color: #800080;">$this</span>->image,<span style="color: #800080;">$color</span>[0],<span style="color: #800080;">$color</span>[1],<span style="color: #800080;">$color</span>[2],<span style="color: #800080;">$color</span>[3<span style="color: #000000;">]); imagestring(</span><span style="color: #800080;">$this</span>->image,<span style="color: #800080;">$fontsize</span>,<span style="color: #800080;">$x</span>,<span style="color: #800080;">$y</span>,<span style="color: #800080;">$text</span>,<span style="color: #800080;">$col</span><span style="color: #000000;">); } </span><span style="color: #008000;">/*</span><span style="color: #008000;"> * 输出图片到浏览器中 </span><span style="color: #008000;">*/</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> show(){ </span><span style="color: #008080;">header</span>('content-type:' . <span style="color: #800080;">$this</span> -> info['mime'<span style="color: #000000;">]); </span><span style="color: #800080;">$fun</span>='image' . <span style="color: #800080;">$this</span>->info['type'<span style="color: #000000;">]; </span><span style="color: #800080;">$fun</span>(<span style="color: #800080;">$this</span>-><span style="color: #000000;">image); } </span><span style="color: #008000;">/*</span><span style="color: #008000;">* * 销毁图片 </span><span style="color: #008000;">*/</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> __destruct(){ imagedestroy(</span><span style="color: #800080;">$this</span>-><span style="color: #000000;">image); }}</span><span style="color: #008000;">//</span><span style="color: #008000;">对类的调用</span><span style="color: #800080;">$obj</span> = <span style="color: #0000ff;">new</span> Image_class('001.png'<span style="color: #000000;">);</span><span style="color: #800080;">$obj</span>->fontMark(20,20,30,<span style="color: #0000ff;">array</span>(255,255,255,60),'hello'<span style="color: #000000;">);</span><span style="color: #800080;">$obj</span>->show();

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

Video Face Swap
Échangez les visages dans n'importe quelle vidéo sans effort grâce à notre outil d'échange de visage AI entièrement gratuit !

Article chaud

Outils chauds

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Sujets chauds





Une erreur se produit lorsque Ubuntu monte un disque dur mobile : mount: unknownfilesystemtype'exfat' La méthode de traitement est la suivante : Ubuntu13.10 ou installez exfat-fuse : sudoapt-getinstallexfat-fuseUbuntu13.04 ou version antérieure sudoapt-add-repositoryppa:relan. /exfatsudoapt-getupdatesudoapt-getinstallfuse- exfatCentOS Linux montage solution d'erreur de disque USB au format exfat pour charger extfa dans CentOS

L'utilisation du mot-clé Type dans Go inclut la définition de nouveaux alias de type ou la création de nouveaux types de structure. Introduction détaillée : 1. Alias de type. Utilisez le mot-clé "type" pour créer un alias pour un type existant. Cet alias ne crée pas un nouveau type, mais fournit uniquement un nouveau nom pour le type existant. Les alias de type peuvent améliorer le code. la lisibilité du code rend le code plus clair ; 2. Type de structure Utilisez le mot-clé "type" pour créer un nouveau type de structure qui peut être utilisé pour définir des types personnalisés contenant plusieurs champs, etc.

Cet article présente sept façons d'obtenir une sortie de haute qualité à l'aide du logiciel gratuit BingImageCreator. BingImageCreator (maintenant connu sous le nom d'ImageCreator pour Microsoft Designer) est l'un des grands générateurs d'art d'intelligence artificielle en ligne. Il génère des effets visuels très réalistes basés sur les invites de l'utilisateur. Plus vos invites sont spécifiques, claires et créatives, meilleurs seront les résultats. BingImageCreator a fait des progrès significatifs dans la création d'images de haute qualité. Il utilise désormais le mode d'entraînement Dall-E3, affichant un niveau de détail et de réalisme plus élevé. Cependant, sa capacité à produire des résultats HD de manière cohérente dépend de plusieurs facteurs, notamment la rapidité

Comment supprimer des images sur les téléphones mobiles Xiaomi ? Vous pouvez supprimer des images sur les téléphones mobiles Xiaomi, mais la plupart des utilisateurs ne savent pas comment supprimer des images. Voici ensuite le didacticiel sur la façon de supprimer des images sur les téléphones mobiles Xiaomi proposé par l'éditeur. pouvez venir nous rejoindre. Voyons! Comment supprimer des images sur le téléphone mobile Xiaomi 1. Ouvrez d'abord la fonction [Album] dans le téléphone mobile Xiaomi ; 2. Vérifiez ensuite les images inutiles et cliquez sur le bouton [Supprimer] dans le coin inférieur droit ; en haut pour accéder à la zone spéciale, sélectionnez [Corbeille] ; 4. Cliquez ensuite directement sur [Vider la corbeille] comme indiqué dans la figure ci-dessous. 5. Enfin, cliquez directement sur [Suppression permanente] pour terminer.

LINUX est un système d'exploitation open source. Sa flexibilité et sa personnalisation en font le premier choix de nombreux développeurs et administrateurs système. Dans le système LINUX, le traitement d'image est une tâche très importante, et Imagemagick et Image sont deux outils de traitement d'image très populaires. L'article vous expliquera comment installer Imagemagick et Image dans le système Centos et fournira des didacticiels d'installation détaillés. Installation d'Imagemagic Tutoriel Centos Imagemagick est un puissant ensemble d'outils de traitement d'image, qui peut effectuer diverses opérations sur les images sous la ligne de commande. Voici les étapes pour installer Imagemagick sur le système Centos : 1.

Cet article vous aidera à interpréter le code source de Vue et à vous expliquer pourquoi vous pouvez l'utiliser pour accéder aux propriétés de diverses options de Vue2. J'espère qu'il sera utile à tout le monde !

Un collègue est resté bloqué à cause d'un bug signalé par ce problème de pointage de Vue2 qui a provoqué l'utilisation d'une fonction de flèche, entraînant l'impossibilité d'obtenir les accessoires correspondants. Il ne le savait pas quand je le lui ai présenté, puis j'ai délibérément regardé le groupe de communication front-end. Jusqu'à présent, au moins 70 % des programmeurs front-end ne le comprennent toujours pas. Aujourd'hui, je vais partager avec. vous ce lien. Si tout n'est pas clair Si vous ne l'avez pas encore appris, s'il vous plaît, faites-moi une grande gueule.

Dans ce guide, nous en apprendrons plus sur la commande « type » sous Linux. Conditions préalables : Pour effectuer les étapes illustrées dans ce guide, vous avez besoin des composants suivants : Un système Linux correctement configuré. Découvrez comment créer une LinuxVM à des fins de test et d'apprentissage. Compréhension de base de l'interface de ligne de commande La commande Type sous Linux est différente des autres commandes spécifiques à Linux (par exemple : ls, chmod, shutdown, vi, grep, pwd, etc.). Fonction Bash affichée en tant qu'argument. Informations sur le type de commande fourni. $type En plus de Bash, d'autres shells (Zsh, Ksh, etc.) sont également livrés avec
