Welcome Guest, Not a member yet? Register   Sign In
Multiple Watermarks
#1

[eluser]bernstable[/eluser]
Using Image_lib I want to 'watermark' the various fields on a jpeg invite for printout. To, from, date, time etc etc. I can easily get one of the fields 'populated' using the following:-

Code:
$config['image_library'] = 'gd';
$config['source_image'] = "./images/invites/163-17.jpg";
$config['wm_text'] = 'Adam';
$config['wm_type'] = 'text';
$config['wm_font_path'] = './system/fonts/comic.ttf';
$config['wm_font_size'] = '50';
$config['wm_font_color'] = 'ffffff';
$config['wm_vrt_offset'] = '1620';
$config['wm_hor_offset'] = '-400';
$config['dynamic_output'] = 'TRUE';
$this->load->library('image_lib', $config);
$this->image_lib->watermark();

Now I just need to add the other fields. how on earth do I manage that - you'll notice that the output is just to the browser
Code:
$config['dynamic_output']='TRUE';
as I am hoping to be able to create the fully populated invite without having to save anything to disc. Any help would be much appreciated.

Bernie

edit: Oops think this is in wrong part of forum.
#2

[eluser]squarebones[/eluser]
You might want to try something like this (off the top of my brain-box), but I ran into similar problems using the resize() function trying to resize two images from one form post.

Firstly, load the image_lib library using $this->load->library('image_lib');
Second, create an array of text you want to display on the image.
Third, loop through that array of text and set your $config parameters appropriately (change your wm_text, wm_vrt_alignment, wm_hor_alignment settings, for instance).
Third, use $this->image_lib->initialize($config); to load your parameters.
Fourth, do your $this->image_lib->watermark(); function.
Fifth, loop ends.

This may work, and may not, but it seems like logically this would work for you, though for dynamic output, it may not as it's dumping the image to the browser instead of modifying a file. Perhaps try this on a static file first, and as the last step in the loop set the dynamic parameter to true.
#3

[eluser]bernstable[/eluser]
Thanks for that suggestion.

Using the array certainly reduces the code but it seems that I've got to save the image to disc at each step otherwise it just doesn't work - unless I'm missing something (which I'll admit is a distinct possibility!).

Its workable saving each stage to disc but it does seem a little (if not a lot!) un-necessary!

Bernie
#4

[eluser]fildawg[/eluser]
Similar situation. Do I need to call $this->image_lib->initialize($config) for each watermark I want to add?
#5

[eluser]BrianDHall[/eluser]
[quote author="bernstable" date="1234542636"]Thanks for that suggestion.

Using the array certainly reduces the code but it seems that I've got to save the image to disc at each step otherwise it just doesn't work - unless I'm missing something (which I'll admit is a distinct possibility!).

Its workable saving each stage to disc but it does seem a little (if not a lot!) un-necessary!

Bernie[/quote]

You are correct, you will need to save to disc through the intermediate steps I'm afraid. This is a limitation of the image libraries in PHP themselves, there are very few functions that permit them to work on a variable of stream input - they expect a real file path to function.

You can, however, just set the dynamic flag on the last step and when done call unlink() on the temporary file. I know its not the ideal, but image libraries are seemingly hard-coded to use real files instead of variable input.




Theme © iAndrew 2016 - Forum software by © MyBB