ksealey ksealey - 4 months ago 27
PHP Question

Getting image resource from SVG (Vector) in PHP

I have been searching the web high and low looking for a way to generate an image resource for a vector(svg) image so I can do some image manipulation (Merging two vectors). I have yet to find a function or some sort of equivalent to

imagecreatefrompng
or
imagecreatefromjpeg
. Any help would be appreciated. I may just be going down the wrong path

Answer

I achieved the result I needed using CSS and javascript/jQuery

HTML

<div class="image-container">
    <img src="http://something.com/img1.png" class="img image1"/>
</div>

CSS

.img{
    /*Set all images with this class to be on the top left of the screen*/
    display:block;
    width:100px;
    height:100px;
    position:absolute;
    left:10px;
    top:10px
}

.image1{
    z-index:1;
}

.image2{
    /*Make image 2 overlay image 1*/
    z-index:2;
}

Javascript

$("#button").click(function(e){
    e.preventDefault();
    var img2 = $('<img src="http://something.com/img2.png"/>')
    img2.addClass("img").addClass("image2")
    $(".image1").after(img2)
})
Comments