View Full Version : Resolved Copyright Script?
theremotedr
09-05-2012, 12:44 PM
I have had a look around but did not find the answer.
Please advise if there is such a script that would apply a copyright logo to photos that are uploaded to my web page.
Should anyone use the right click save as option etc then the downloaded photo would have this copyright on the photo.
jscheuer1
09-05-2012, 03:04 PM
I would think that would have to be server side. If you have PHP, have you checked these out:
https://www.google.com/search?rls=en&q=php+add+watermark+to+image
?
If you're using a different server side language, you could do a similar search on it.
djr33
09-05-2012, 03:50 PM
It is not possible to do this only when downloaded.
If it possible to add a watermark to images when they are displayed on the website and when they are downloaded as well.
The same idea works with using low resolution (small) images rather than full quality ones-- if you never give the visitor a full quality or unwatermarked copy of your image, then they can't still it because it just doesn't exist.
I wasn't sure if you wanted to have the watermark when the image was viewed, or only when downloaded-- that's just not possible, in the same way that it's not possible to stop someone from saving the image in the first place. The solution that can almost always get around any kind of protection is a screen capture, and that would take a picture of the image as it is displayed, without a watermark. So it's either always or never-- your choice.
As for John's link, that's where to start-- PHP is a good option (and most accessible, although there are some alternatives if necessary). I would actually suggest doing them manually on your computer then uploading them like that. It will take a little time, but realistically how many images do you have? Only if you have hundreds (or thousands) of images would I really think it is worth doing it on the website-- it's fairly difficult/technical to set that up, and once you do it will take a significant amount of processing power from the server to run that, especially on large images.
If you do it, make sure you convert it when uploading rather than generating the watermarked image every time when you display it-- that would be slow and waste a lot of processing on the server, and your host might get upset with you for wasting resources (it happens often with PHP+images).
It is not possible to do this only when downloaded.
more to the point, you can't "view" an image without downloading it first, so there really is no difference in the two situations as far as the web is concerned.
jscheuer1
09-05-2012, 09:01 PM
I'm pretty sure theremotedr was asking how to put the watermark on the image after it was uploaded and before it was displayed. If so, that's no problem except that for larger images or for a lot of them at once it might be a bit of a load on the server. Doing them more or less one at time on the server as they're uploaded by the users shouldn't be too bad though. If that's the scenario. It would be a nice touch to also save a copy without the watermark, one not to be displayed, but accessible to theremotedr if (s)he would like to have that. That also should be no problem to arrange.
On the other hand, if these are all theremotedr's own images. There are programs you can run on your own computer that can add a watermark to a batch of images very quickly. If that's the scenario and there are a lot of images, if they're all your images, that approach would be better. Just mark 'em and upload 'em. If it's just a few of your images, doing them one at a time locally before uploading wouldn't be too bad either.
djr33
09-05-2012, 09:15 PM
There are programs you can run on your own computer that can add a watermark to a batch of images very quickly.Yes. And I (we?) could help if that's the case. Photoshop's actions would allow this, for example, or you could even compile a PHP program into an .exe to do this locally without worrying about server load. It's not the most efficient (fast) way to do it, but as long as your concern isn't the time it takes, that shouldn't matter-- just let it run over night if need be. (But to be honest if you can do it another way you may as well, because modifying images in PHP can be hard to code, in addition to slow/server-intensive.)
bernie1227
09-06-2012, 09:07 AM
It would be easy enough to just add a watermark to any uploaded photo, see here (http://x10hosting.com/forums/tutorials/108812-watermark-uploaded-image-using-php.html) for a tutorial on that.
theremotedr
09-06-2012, 09:37 AM
Sounds ok but where do you put all the code.
bernie1227
09-06-2012, 09:43 AM
this code is for the uploading part of it
theremotedr
09-09-2012, 08:20 PM
Hi
I have installed the script and working pretty much all ok.
Now and then it will not allow file to be uploaded and the error message is,,,Please browse for a file before clicking the upload button.
Any reasons why i receive this message with some photos.
I have tried say 10 photos that give me this message and each time the same.
I also noticed that the script generates 3 images in the uploads folder.
one original photo
one resized photo
one resized photo with watermark
As i only use the photo with the watermark is there a tweak we can apply to the code so only the photo with the watermark is produced ?
Many thanks.
theremotedr
09-09-2012, 08:43 PM
I have noticed that all photos that did not allow to be uploaded are all 3872 x 2592 in size.
djr33
09-09-2012, 10:09 PM
Is that the largest size? It may just not be able to handle something that big. Generally speaking anything over 1000px (in either direction) is going to be a LOT of work for the server, even running it once. I'd highly recommend using another method if you don't have a dedicated server.
theremotedr
09-09-2012, 10:20 PM
I will resize them then.
Did you read about any code available etc so only the watermarked photo is generated & not 3 photos.
Thanks
djr33
09-09-2012, 10:28 PM
No, but I imagine you could change that script to generate that if you want to modify it.
I really think the best option for this is doing it on your computer and uploading the final images, but it's up to you. You'll have a lot more control that way.
theremotedr
09-09-2012, 10:37 PM
I am uploading the photos with the watermarks.
I just end up with a folder of 2 photos for each photos generated that i need to delete all the time,not a huge problem but nice if it only the generated the photo with the watermark.
I do not know how to write code to allow this to be possible.
keyboard
09-09-2012, 11:42 PM
I'd just like to point out (if this hasen't already been said & it's relevant) that by keeping the original un-watermarked photo in on your webserver, the users can probably just navigate to that directory and download the un-marked one anyway.
theremotedr
09-09-2012, 11:52 PM
Only the photo with the watermark is used.
Thanks anyway
djr33
09-10-2012, 12:18 AM
I'd just like to point out (if this hasen't already been said & it's relevant) that by keeping the original un-watermarked photo in on your webserver, the users can probably just navigate to that directory and download the un-marked one anyway. Technically, but not if they don't know where it is or don't even know to look for it.
theremotedr
09-10-2012, 12:25 AM
Hi djr33
Are you able to edit the script so only the watermarked photo is generated ?
djr33
09-10-2012, 12:44 AM
I think this is something you should be able to do yourself. It will be much easier to figure it out within your system anyway. (And I'm too busy at the moment.)
I don't actually see where it saves all of these extra copies. It looks like that function just creates a new watermarked copy. So, instead of doing it that way, just don't save the original copy and then allow this to create the only copy. Or, the simple answer, use unlink() to delete the file after it's created. That's a bit indirect, but it would work.
theremotedr
09-10-2012, 01:04 AM
There is a folder called UPLOADS
The script generates 3 photos from the photo you upload.
1,one photo is the origianl size that was selected to be used
2,one photo is the resized output sized photo
3,one photo is the resized output sized photo with a watermark
I do not need 1 & 2 to be generated.
If i knew how to write code or scripts i would but i dont some looking for some help.
I can supply the text in the script file if that helps to look and edit for me ?
djr33
09-10-2012, 02:31 AM
As I said, I'm too busy to put much time into this at the moment. If you post the code, I can take a quick look, but if I don't see what's wrong I won't be able to take the time to debug it.
Either:
1) The image is copied using move_uploaded_file(), just when it was uploaded in the first place.
Or:
2) The image is created using imagejpeg() or imagepng() or imagegif().
Stopping it should be as simple as finding that line and commenting it out.
Also, as I said above, if you use unlink(), you can delete the files after they're created. It's slightly less efficient than not creating them at all, but that should be very easy to do. See the php.net page for more information-- you'll just need to find the right path for the image and that's it.
Another reason I don't want to put a lot of time into this is that if I were in your position, I'd just do it locally anyway. I think you're going to run into problems doing it this way, or at the very least put more time into setting this up than it would ever take you to just do it locally.
theremotedr
09-10-2012, 08:22 AM
Here is the script thanks.
Like i mentioned the script puts 3 photos in the uploads folder.
1 the original size photo.
2,the resized photo without watermark set to the size of the output file size.
3,the resized photo with a watermark set to the size of the output file size.
My output file size is set at 1024 x 768
Once the photos are in the uploads folder i only have use for the photo with the watermark.
The other two photos are deleted.
This is why i would like a tweak in the script to not generate these two files or delete as soon as there are generated.
<?php
// Access the $_FILES global variable for this specific file being uploaded
// and create local PHP variables from the $_FILES array of information
$fileName = $_FILES["uploaded_file"]["name"]; // The file name
$fileTmpLoc = $_FILES["uploaded_file"]["tmp_name"]; // File in the PHP tmp folder
$fileType = $_FILES["uploaded_file"]["type"]; // The type of file it is
$fileSize = $_FILES["uploaded_file"]["size"]; // File size in bytes
$fileErrorMsg = $_FILES["uploaded_file"]["error"]; // 0 for false... and 1 for true
$fileName = preg_replace('#[^a-z.0-9]#i', '', $fileName); // filter
$kaboom = explode(".", $fileName); // Split file name into an array using the dot
$fileExt = end($kaboom); // Now target the last array element to get the file extension
// START PHP Image Upload Error Handling -------------------------------
if (!$fileTmpLoc) { // if file not chosen
echo "ERROR: Please browse for a file before clicking the upload button.";
exit();
} else if($fileSize > 5242880) { // if file size is larger than 5 Megabytes
echo "ERROR: Your file was larger than 5 Megabytes in size.";
unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder
exit();
} else if (!preg_match("/.(gif|jpg|png)$/i", $fileName) ) {
// This condition is only if you wish to allow uploading of specific file types
echo "ERROR: Your image was not .gif, .jpg, or .png.";
unlink($fileTmpLoc); // Remove the uploaded file from the PHP temp folder
exit();
} else if ($fileErrorMsg == 1) { // if file upload error key is equal to 1
echo "ERROR: An error occured while processing the file. Try again.";
exit();
}
// END PHP Image Upload Error Handling ---------------------------------
// Place it into your "uploads" folder mow using the move_uploaded_file() function
$moveResult = move_uploaded_file($fileTmpLoc, "uploads/$fileName");
// Check to make sure the move result is true before continuing
if ($moveResult != true) {
echo "ERROR: File not uploaded. Try again.";
exit();
}
// Include the file that houses all of our custom image functions
include_once("ak_php_img_lib_1.php");
// ---------- Start Adams Universal Image Resizing Function --------
$target_file = "uploads/$fileName";
$resized_file = "uploads/resized_$fileName";
$wmax = 1024;
$hmax = 768;
ak_img_resize($target_file, $resized_file, $wmax, $hmax, $fileExt);
// ----------- End Adams Universal Image Resizing Function ----------
// ---------- Start Adams Convert to JPG Function --------
if (strtolower($fileExt) != "jpg") {
$target_file = "uploads/resized_$fileName";
$new_jpg = "uploads/resized_".$kaboom[0].".jpg";
ak_img_convert_to_jpg($target_file, $new_jpg, $fileExt);
}
// ----------- End Adams Convert to JPG Function -----------
// ---------- Start Adams Image Watermark Function --------
$target_file = "uploads/resized_".$kaboom[0].".jpg";
$wtrmrk_file = "watermark.png";
$new_file = "C:\Documents and Settings\IAN PARSONS\My Documents\MY WEB SITE STUFF\WEST COUNTRY PHOTOZONE\copyright photos/zcopyright_".$kaboom[0].".jpg";
ak_img_watermark($target_file, $wtrmrk_file, $new_file);
// ----------- End Adams Image Watermark Function -----------
// Display things to the page so you can see what is happening for testing purposes
echo "The file named <strong>$fileName</strong> uploaded successfuly.<br /><br />";
echo "It is <strong>$fileSize</strong> bytes in size.<br /><br />";
echo "It is an <strong>$fileType</strong> type of file.<br /><br />";
echo "The file extension is <strong>$fileExt</strong><br /><br />";
echo "The Error Message output for this upload is: $fileErrorMsg";
?>
djr33
09-11-2012, 08:30 PM
It would be possible to not generate the files, but that would require significantly rewriting the functions. As it is, it generates each then uses those files to generate the next. So if you turned that off in the script, you wouldn't have any file from which to generate the watermark photo.
So the solution here, although it isn't the most elegant, is simply to delete those after they're done processing.
At the end of the script, use the unlink() function with the right path, once for each extra image, to remove them.
http://www.php.net/manual/en/function.unlink.php
With the right paths, that should work immediately. However:
1) Be careful with this-- you're deleting files on the server. If you aren't confident about it, then create a backup of the whole site first and don't use this on an active website. After some testing you should see that it works and you can rely on it.
2) Use only paths generated by you. Don't rely on user input or a clever user might be able to delete other files on the system. This will also mean that you probably want to rename all of the photos rather than using the original names, or they could try to trick the system into deleting other files based on the name of the photo they upload. Of course this also applies to how the files are named in the first place-- they might find a way to overwrite a file that you wanted based on the name of the image-- so renaming all uploads is a good idea. Or filtering the filenames at least.
3) The only possible technical problem will be if there's a permissions error on deleting (unlinking) the file. There shouldn't be, because it's generated by PHP. But if there is, just let us know.
Let us know if you can't figure out the paths. Post your current unlink() code and we can try to help.
theremotedr
09-12-2012, 08:39 AM
Adding the unlink () worked.
Thanks
keyboard
09-13-2012, 01:24 AM
If this thread is finished, please set it to resolved.
You can do this by editing the first post within the thread - Pressing go advanced - Then where it says no prefix, selecting resolved then save.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.