Permalink
Browse files

Image watermark system corrected and tested

  • Loading branch information...
1 parent ec2e417 commit b45f28565b67e4b09aa2ddb78f36861da07dbc7a Carlos Ouro committed Oct 15, 2010
Showing with 39 additions and 9 deletions.
  1. BIN .DS_Store
  2. BIN examples/.DS_Store
  3. +17 −3 examples/images.php
  4. BIN examples/images/2-blue-alpha.png
  5. BIN examples/images/watermark_1.png
  6. BIN examples/uploads/images/fit_outside/samurai.jpg
  7. BIN examples/uploads/images/fit_outside/samurai1.jpg
  8. BIN examples/uploads/images/fit_outside/samurai10.jpg
  9. BIN examples/uploads/images/fit_outside/samurai11.jpg
  10. BIN examples/uploads/images/fit_outside/samurai2.jpg
  11. BIN examples/uploads/images/fit_outside/samurai3.jpg
  12. BIN examples/uploads/images/fit_outside/samurai4.jpg
  13. BIN examples/uploads/images/fit_outside/samurai5.jpg
  14. BIN examples/uploads/images/fit_outside/samurai6.jpg
  15. BIN examples/uploads/images/fit_outside/samurai7.jpg
  16. BIN examples/uploads/images/fit_outside/samurai8.jpg
  17. BIN examples/uploads/images/fit_outside/samurai9.jpg
  18. BIN examples/uploads/images/fit_within/samurai.jpg
  19. BIN examples/uploads/images/fit_within/samurai1.jpg
  20. BIN examples/uploads/images/fit_within/samurai10.jpg
  21. BIN examples/uploads/images/fit_within/samurai11.jpg
  22. BIN examples/uploads/images/fit_within/samurai2.jpg
  23. BIN examples/uploads/images/fit_within/samurai3.jpg
  24. BIN examples/uploads/images/fit_within/samurai4.jpg
  25. BIN examples/uploads/images/fit_within/samurai5.jpg
  26. BIN examples/uploads/images/fit_within/samurai6.jpg
  27. BIN examples/uploads/images/fit_within/samurai7.jpg
  28. BIN examples/uploads/images/fit_within/samurai8.jpg
  29. BIN examples/uploads/images/fit_within/samurai9.jpg
  30. BIN examples/uploads/images/fixed_height/samurai.jpg
  31. BIN examples/uploads/images/fixed_height/samurai1.jpg
  32. BIN examples/uploads/images/fixed_height/samurai10.jpg
  33. BIN examples/uploads/images/fixed_height/samurai11.jpg
  34. BIN examples/uploads/images/fixed_height/samurai2.jpg
  35. BIN examples/uploads/images/fixed_height/samurai3.jpg
  36. BIN examples/uploads/images/fixed_height/samurai4.jpg
  37. BIN examples/uploads/images/fixed_height/samurai5.jpg
  38. BIN examples/uploads/images/fixed_height/samurai6.jpg
  39. BIN examples/uploads/images/fixed_height/samurai7.jpg
  40. BIN examples/uploads/images/fixed_height/samurai8.jpg
  41. BIN examples/uploads/images/fixed_height/samurai9.jpg
  42. BIN examples/uploads/images/fixed_width/samurai.jpg
  43. BIN examples/uploads/images/fixed_width/samurai1.jpg
  44. BIN examples/uploads/images/fixed_width/samurai10.jpg
  45. BIN examples/uploads/images/fixed_width/samurai11.jpg
  46. BIN examples/uploads/images/fixed_width/samurai2.jpg
  47. BIN examples/uploads/images/fixed_width/samurai3.jpg
  48. BIN examples/uploads/images/fixed_width/samurai4.jpg
  49. BIN examples/uploads/images/fixed_width/samurai5.jpg
  50. BIN examples/uploads/images/fixed_width/samurai6.jpg
  51. BIN examples/uploads/images/fixed_width/samurai7.jpg
  52. BIN examples/uploads/images/fixed_width/samurai8.jpg
  53. BIN examples/uploads/images/fixed_width/samurai9.jpg
  54. BIN examples/uploads/images/forced/samurai.jpg
  55. BIN examples/uploads/images/forced/samurai1.jpg
  56. BIN examples/uploads/images/forced/samurai10.jpg
  57. BIN examples/uploads/images/forced/samurai11.jpg
  58. BIN examples/uploads/images/forced/samurai2.jpg
  59. BIN examples/uploads/images/forced/samurai3.jpg
  60. BIN examples/uploads/images/forced/samurai4.jpg
  61. BIN examples/uploads/images/forced/samurai5.jpg
  62. BIN examples/uploads/images/forced/samurai6.jpg
  63. BIN examples/uploads/images/forced/samurai7.jpg
  64. BIN examples/uploads/images/forced/samurai8.jpg
  65. BIN examples/uploads/images/forced/samurai9.jpg
  66. BIN examples/uploads/images/scale/samurai.jpg
  67. BIN examples/uploads/images/scale/samurai1.jpg
  68. BIN examples/uploads/images/scale/samurai10.jpg
  69. BIN examples/uploads/images/scale/samurai11.jpg
  70. BIN examples/uploads/images/scale/samurai2.jpg
  71. BIN examples/uploads/images/scale/samurai3.jpg
  72. BIN examples/uploads/images/scale/samurai4.jpg
  73. BIN examples/uploads/images/scale/samurai5.jpg
  74. BIN examples/uploads/images/scale/samurai6.jpg
  75. BIN examples/uploads/images/scale/samurai7.jpg
  76. BIN examples/uploads/images/scale/samurai8.jpg
  77. BIN examples/uploads/images/scale/samurai9.jpg
  78. BIN examples/uploads/images/specific_scale/samurai.jpg
  79. BIN examples/uploads/images/specific_scale/samurai1.jpg
  80. BIN examples/uploads/images/specific_scale/samurai10.jpg
  81. BIN examples/uploads/images/specific_scale/samurai11.jpg
  82. BIN examples/uploads/images/specific_scale/samurai2.jpg
  83. BIN examples/uploads/images/specific_scale/samurai3.jpg
  84. BIN examples/uploads/images/specific_scale/samurai4.jpg
  85. BIN examples/uploads/images/specific_scale/samurai5.jpg
  86. BIN examples/uploads/images/specific_scale/samurai6.jpg
  87. BIN examples/uploads/images/specific_scale/samurai7.jpg
  88. BIN examples/uploads/images/specific_scale/samurai8.jpg
  89. BIN examples/uploads/images/specific_scale/samurai9.jpg
  90. BIN examples/uploads/images/thumb/samurai.jpg
  91. BIN examples/uploads/images/thumb/samurai1.jpg
  92. BIN examples/uploads/images/thumb/samurai10.jpg
  93. BIN examples/uploads/images/thumb/samurai11.jpg
  94. BIN examples/uploads/images/thumb/samurai2.jpg
  95. BIN examples/uploads/images/thumb/samurai3.jpg
  96. BIN examples/uploads/images/thumb/samurai4.jpg
  97. BIN examples/uploads/images/thumb/samurai5.jpg
  98. BIN examples/uploads/images/thumb/samurai6.jpg
  99. BIN examples/uploads/images/thumb/samurai7.jpg
  100. BIN examples/uploads/images/thumb/samurai8.jpg
  101. BIN examples/uploads/images/thumb/samurai9.jpg
  102. BIN examples/uploads/images/watermarked/samurai.jpg
  103. BIN examples/uploads/images/watermarked/samurai1.jpg
  104. BIN examples/uploads/images/watermarked/samurai10.jpg
  105. BIN examples/uploads/images/watermarked/samurai11.jpg
  106. BIN examples/uploads/images/watermarked/samurai2.jpg
  107. BIN examples/uploads/images/watermarked/samurai3.jpg
  108. BIN examples/uploads/images/watermarked/samurai4.jpg
  109. BIN examples/uploads/images/watermarked/samurai5.jpg
  110. BIN examples/uploads/images/watermarked/samurai6.jpg
  111. BIN examples/uploads/images/watermarked/samurai7.jpg
  112. BIN examples/uploads/images/watermarked/samurai8.jpg
  113. BIN examples/uploads/images/watermarked/samurai9.jpg
  114. +4 −2 nphp/libs/Disk.php
  115. +18 −4 nphp/libs/Image.php
View
Binary file not shown.
View
Binary file not shown.
View
@@ -14,10 +14,24 @@
"fit_within" => "100x200>",
"fit_outside" => "100x200^",
"forced" => "200x200!",
- 'thumb' => "100x100#"));
+ 'thumb' => "100x100#",
+ 'watermarked' => "300x300"
+ ));
+
+//set watermark
+$image->set_watermark(Path::to("images/watermark_1.png", __FILE__), array('watermarked'));
//saves all children
$filename = $image->save_children(array('folder' => Path::to("uploads/images", __FILE__)));
-var_dump($filename);
-?>
+?>
+<img src="<?php Path::put('uploads/images/Samurai.jpg', __FILE__); ?>" />
+<img src="<?php Path::put('uploads/images/scale/'.$filename, __FILE__); ?>" />
+<img src="<?php Path::put('uploads/images/specific_scale/'.$filename, __FILE__); ?>" />
+<img src="<?php Path::put('uploads/images/fixed_width/'.$filename, __FILE__); ?>" />
+<img src="<?php Path::put('uploads/images/fixed_height/'.$filename, __FILE__); ?>" />
+<img src="<?php Path::put('uploads/images/fit_within/'.$filename, __FILE__); ?>" />
+<img src="<?php Path::put('uploads/images/fit_outside/'.$filename, __FILE__); ?>" />
+<img src="<?php Path::put('uploads/images/forced/'.$filename, __FILE__); ?>" />
+<img src="<?php Path::put('uploads/images/thumb/'.$filename, __FILE__); ?>" />
+<img src="<?php Path::put('uploads/images/watermarked/'.$filename, __FILE__); ?>" />
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
View
@@ -56,11 +56,13 @@ static function unique_filename( $dir, $filename, $unique_filename_callback = nu
$ext = strtolower( ".$ext" );
// Strip % so the server doesn't try to decode entities.
- $filename = str_replace('%', '', self::sanitize_file_name( $name ) ) . $ext;
+ $s_name = str_replace('%', '', self::sanitize_file_name( $name ));
+
+ $filename = $s_name . $ext;
while ( file_exists( $dir . "/$filename" ) ) {
if ( ! $number )
- $filename = $name . ++$number . $ext;
+ $filename = $s_name . ++$number . $ext;
else
$filename = str_replace( "$number$ext", ++$number . $ext, $filename );
}
View
@@ -171,6 +171,8 @@ static function from_file($file){
case 3:
// creates an image from file
$image = @imagecreatefrompng($options['path']);
+ imagealphablending($image, true);
+ imagesavealpha($image, true);
break;
default:
// if file has an unsupported extension
@@ -200,6 +202,8 @@ public function new_resource($with, $height){
isset($this->options['transparentColorRed']) &&
isset($this->options['transparentColorGreen']) &&
isset($this->options['transparentColorBlue'])) {
+
+
$image['transparentColorRed']=$this->options['transparentColorRed'];
$image['transparentColorGreen']=$this->options['transparentColorGreen'];
$image['transparentColorBlue']=$this->options['transparentColorBlue'];
@@ -210,7 +214,17 @@ public function new_resource($with, $height){
$image['transparentColorBlue']);
imagefilledrectangle($image['resource'], 0, 0, $image['width'], $image['height'], $transparent);
imagecolortransparent($image['resource'], $transparent);
- }
+ //png transparency
+ } elseif($this->info['type'] == 3){
+
+ imagealphablending($image['resource'], true);
+
+ $color = imagecolortransparent($image['resource'], imagecolorallocatealpha($image['resource'], 0, 0, 0, 127));
+
+ imagefill($image['resource'], 0, 0, $color);
+ imagesavealpha($image['resource'], true);
+
+ }
// return new image resource
return $image;
}
@@ -372,14 +386,14 @@ function set_watermark($file, $styles='all', $original_too=false){
//transforms children
foreach($this->children as $child){
- if($styles=='all' || in_array()) $child['instance']->set_watermark($this->watermark);
+ if($styles=='all' || in_array($child['name'], $styles)){
+ $child['instance']->set_watermark($this->watermark); }
}
//transforms original
if($styles=='all' || $original_too){
$this->watermark->resize($this->info['width'].'x'.$this->info['height'].'#');
-
- imagecopymerge($this->image, $this->watermark->image, 0, 0, 0, 0, $this->info['width'], $this->info['height'], 100);
+ imagecopy($this->image, $this->watermark->image, 0, 0, 0, 0, $this->info['width'], $this->info['height']);
}
}

0 comments on commit b45f285

Please sign in to comment.