I am making some web photo gallery and I decided to make there some basic stuff for customizing your images, like change their width
, height
, make some borders around that and other stuff. For now I have very simple javascript methods for changing the width
and height
of my image, something like this:
function smaller() {
var image = document.getElementById('forchange');
var width = image.clientWidth;
var height = image.clientHeight;
image.height = height - 50;
image.width = width - 50;
}
function bigger() {
var image = document.getElementById('forchange');
var width = image.clientWidth;
var height = image.clientHeight;
image.height = height + 50;
image.width = width + 50;
}
HTML
{block content}
{snippet changePhoto}
<img src="{$photo}" id="forchange">
{/snippet}
<label>Velkosť </label>
<button type="submit" onclick="bigger()" value="{$photo}" name="bigger">+</button>
<button type="submit" onclick="smaller()" value="{$photo}" name="smaller">-</button>
<form action="{link Gallery:change $photo}" method="post" >
<input type = "submit" value="ulozit" name="save">
</form>
It's working the image is smaller or bigger according to what button I press but, after refreshing the page the image is in same width and height as it was (logically).
How can I save or rewrite the current image file saved on my disk so after refresh the page I can see the new image which I customized as I wanted to? Is it possible to do something like that?
I searched on web a lot, I found some stuff about canvas and lot of things but none of that seemed like it's what I need. Thank you all very much for every answer.