Saved!

PHP Script Watermark Image - T74iwW3Y

javascript codeeditor textarea to editeble pre

php upload image watermark resize

  
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js" type="text/javascript"></script>	
<h1></h1>

<pre id="layer" contentEditable="true"></pre>

<textarea id="highlight" name="highlight">
<?php
// File and new size
$filename = 'images/'.$_GET['img'];


    function watermark_image($target, $wtrmrk_file, $newcopy) {

        $watermark = imagecreatefrompng($wtrmrk_file);
        //$watermark = imagescale($watermark, 1000, 1000);
        imagealphablending($watermark, false);
        imagesavealpha($watermark, true);
        $size = getimagesize($target);
        switch ($size['mime']) {
            case "image/gif":
                $img = @imagecreatefromgif($target);
            break;
            case "image/jpeg":
                $img = @imagecreatefromjpeg($target);
            break;
            case "image/png":
                $img = @imagecreatefrompng($target);
            break;
        } 

        $img_w = imagesx($img);
        $img_h = imagesy($img);
        $wtrmrk_w = imagesx($watermark);
        $wtrmrk_h = imagesy($watermark);

        //$dst_x = ($img_w / 2) - ($wtrmrk_w / 2); // For centering the watermark on any image
        //$dst_y = ($img_h / 2) - ($wtrmrk_h / 2); // For centering the watermark on any image

        $dst_x = ($img_w - 1000); // For centering the watermark on any image
        $dst_y = ($img_h - 1000); // For centering the watermark on any image

        imagecopy($img, $watermark, $dst_x, $dst_y, 0, 0, $wtrmrk_w, $wtrmrk_h);

        //imagejpeg($img, $newcopy, 85);

        header('Content-Type: image/jpeg');

        imagejpeg($img);
        imagedestroy($img);
        imagedestroy($watermark);
    }

    watermark_image($filename,'watermark.png', $filename);
?>
</textarea>  
  
Meta
http://codesheet.org/placehold-img/?width=300&height=250&color=33aaff&text=&textcolor=

Quick add:

× Clear

Add Stylesheets

normalize.css
reset.css
nice.css
/> CodeSheet UI
Font Awesome
Bootstrap
Foundation
Animate

Add External JavaScript

jQuery 3.1.0
jQuery UI
Bootstrap
Angular

Add Google Fonts

Dosis
Exo+2
Lato
Lobster
Open+Sans
Open+Sans+Condensed
Oswald
Playfair+Display
Quicksand
Raleway
Rochester
Roboto
Roboto+Condensed
Roboto+Mono
Shadows+Into+Light
Ubuntu
Arvo
Indie Flower
Merriweather
Pacifico
Sedgwick Ave
Sedgwick Ave Display
html
css
js