Rollback emboss module to gallery3-contrib/master
This commit is contained in:
parent
7b5e2cae7c
commit
bf2dd87153
@ -333,7 +333,7 @@ class emboss_Core {
|
|||||||
|
|
||||||
$has_changes=0;
|
$has_changes=0;
|
||||||
foreach ($images as $image) {
|
foreach ($images as $image) {
|
||||||
$overlay_id = emboss::determine_best_overlay($image->width,$image->height,$overlays);
|
$overlay_id = emboss::determine_best_overlay($image,$overlays);
|
||||||
if($overlay_id < 0) {
|
if($overlay_id < 0) {
|
||||||
$n_none++;
|
$n_none++;
|
||||||
}
|
}
|
||||||
@ -378,7 +378,7 @@ class emboss_Core {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function determine_best_overlay($W,$H,$overlays=NULL)
|
static function determine_best_overlay($image,$overlays=NULL)
|
||||||
{
|
{
|
||||||
if(!$overlays) {
|
if(!$overlays) {
|
||||||
$overlays = ORM::factory('emboss_overlay')->where('active','=',1)->find_all();
|
$overlays = ORM::factory('emboss_overlay')->where('active','=',1)->find_all();
|
||||||
@ -387,8 +387,8 @@ class emboss_Core {
|
|||||||
$method = module::get_var('emboss','method');
|
$method = module::get_var('emboss','method');
|
||||||
$size = 0.01 * module::get_var('emboss','size');
|
$size = 0.01 * module::get_var('emboss','size');
|
||||||
|
|
||||||
$W *= $size;
|
$W = $size * $image->width;
|
||||||
$H *= $size;
|
$H = $size * $image->height;
|
||||||
|
|
||||||
$bestID = -1;
|
$bestID = -1;
|
||||||
$bestScore=0;
|
$bestScore=0;
|
||||||
@ -454,55 +454,6 @@ class emboss_Core {
|
|||||||
|
|
||||||
log::info('emboss','module uninstalled (database dropped/overlays removed)');
|
log::info('emboss','module uninstalled (database dropped/overlays removed)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function copy_orig_to_album($item,$delta)
|
|
||||||
{
|
|
||||||
$itempath = $item->file_path();
|
|
||||||
$origpath = str_replace(VARPATH.'albums/',VARPATH.'originals/',$itempath);
|
|
||||||
|
|
||||||
$q = db::build()
|
|
||||||
->select('cur_rotation')
|
|
||||||
->from('emboss_mappings')
|
|
||||||
->where('image_id','=',$item->id)
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$old_rot = $q[0]->cur_rotation;
|
|
||||||
$new_rot = ($old_rot + $delta + 360)%360;
|
|
||||||
|
|
||||||
db::build()
|
|
||||||
->update('emboss_mappings')
|
|
||||||
->where('image_id','=',$item->id)
|
|
||||||
->set('cur_rotation',$new_rot)
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
@unlink($itempath);
|
|
||||||
@copy($origpath,$itempath);
|
|
||||||
|
|
||||||
Image::factory($itempath)
|
|
||||||
->quality(module::get_var('gallery', 'image_quality'))
|
|
||||||
->rotate($old_rot)
|
|
||||||
->save($itempath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function reemboss_rotation($item)
|
|
||||||
{
|
|
||||||
// no, the following isn't backwards
|
|
||||||
// After rotation, width and height are swapped
|
|
||||||
// The $item object is from before rotation
|
|
||||||
$new_overlay = emboss::determine_best_overlay($item->height,$item->width);
|
|
||||||
|
|
||||||
db::build()
|
|
||||||
->update('emboss_mappings')
|
|
||||||
->where('image_id','=',$item->id)
|
|
||||||
->set('best_overlay_id',$new_overlay)
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
db::build()
|
|
||||||
->update('emboss_mappings')
|
|
||||||
->where('image_id','=',$item->id)
|
|
||||||
->set('cur_overlay_id',-1)
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
emboss::check_for_dirty();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class emboss_event_Core {
|
|||||||
|
|
||||||
$q = ORM::factory('emboss_mapping');
|
$q = ORM::factory('emboss_mapping');
|
||||||
$q->image_id = $item->id;
|
$q->image_id = $item->id;
|
||||||
$q->best_overlay_id = emboss::determine_best_overlay($item->width,$item->height);
|
$q->best_overlay_id = emboss::determine_best_overlay($item);
|
||||||
$q->cur_overlay_id = -1;
|
$q->cur_overlay_id = -1;
|
||||||
$q->cur_gravity = '';
|
$q->cur_gravity = '';
|
||||||
$q->cur_transparency = -1;
|
$q->cur_transparency = -1;
|
||||||
@ -117,14 +117,5 @@ class emboss_event_Core {
|
|||||||
emboss::check_for_dirty();
|
emboss::check_for_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function graphics_rotate($in,$out,$opts,$item)
|
|
||||||
{
|
|
||||||
emboss::copy_orig_to_album($item,$opts['degrees']);
|
|
||||||
}
|
|
||||||
|
|
||||||
static function graphics_rotate_completed($in,$out,$opts,$item)
|
|
||||||
{
|
|
||||||
emboss::reemboss_rotation($item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,14 +45,9 @@ class emboss_installer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function upgrade($version)
|
static function upgrade($version)
|
||||||
{
|
{
|
||||||
$db = Database::instance();
|
module::set_version('emboss',$verion=1);
|
||||||
if($version==1)
|
log::info('emboss',"Upgrade to version $version / No action taken");
|
||||||
{
|
|
||||||
$db->query("ALTER TABLE {emboss_mappings} ADD COLUMN `cur_rotation` int(9) default 0");
|
|
||||||
module::set_version('emboss',2);
|
|
||||||
log::info('emboss',"Upgraded to version 2 / Added Column cur_rotation");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function activate()
|
static function activate()
|
||||||
|
@ -45,8 +45,7 @@ class emboss_task_Core {
|
|||||||
foreach ($q as $item) {
|
foreach ($q as $item) {
|
||||||
$ids[] = array('id'=>$item->id,
|
$ids[] = array('id'=>$item->id,
|
||||||
'image_id'=>$item->image_id,
|
'image_id'=>$item->image_id,
|
||||||
'overlay_id'=>$item->best_overlay_id,
|
'overlay_id'=>$item->best_overlay_id);
|
||||||
'rotation'=>$item->cur_rotation);
|
|
||||||
}
|
}
|
||||||
$count = count($ids);
|
$count = count($ids);
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ class emboss_task_Core {
|
|||||||
$current++;
|
$current++;
|
||||||
$task->set('current',$current);
|
$task->set('current',$current);
|
||||||
|
|
||||||
emboss_task::do_embossing($id['id'],$id['image_id'],$id['overlay_id'],$id['rotation']);
|
emboss_task::do_embossing($id['id'],$id['image_id'],$id['overlay_id']);
|
||||||
|
|
||||||
if($current>=$count) {
|
if($current>=$count) {
|
||||||
$task->done = true;
|
$task->done = true;
|
||||||
@ -102,7 +101,7 @@ class emboss_task_Core {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function do_embossing($id,$image_id,$overlay_id,$rotation)
|
static function do_embossing($id,$image_id,$overlay_id)
|
||||||
{
|
{
|
||||||
$gravity = module::get_var('emboss','gravity');
|
$gravity = module::get_var('emboss','gravity');
|
||||||
$transparency = module::get_var('emboss','transparency');
|
$transparency = module::get_var('emboss','transparency');
|
||||||
@ -125,26 +124,9 @@ class emboss_task_Core {
|
|||||||
$opts['position'] = $gravity;
|
$opts['position'] = $gravity;
|
||||||
$opts['transparency'] = 100-$transparency;
|
$opts['transparency'] = 100-$transparency;
|
||||||
|
|
||||||
if($rotation==0)
|
log::info('emboss','Embossing '.$item->name.' with '.$overlay->name);
|
||||||
{
|
|
||||||
log::info('emboss','Embossing '.$item->name.' with '.$overlay->name);
|
|
||||||
gallery_graphics::composite($orig,$path,$opts);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log::info('emboss','Embossing Rotation('.$rotation.') '.$item->name.' with '.$overlay->name);
|
|
||||||
$orig_path = explode('/',$orig);
|
|
||||||
$orig_name = array_pop($orig_path);
|
|
||||||
$orig_path = implode('/',$orig_path);
|
|
||||||
$rotpath = $orig_path.'/rotated_'.$orig_name;
|
|
||||||
|
|
||||||
Image::factory($orig)
|
gallery_graphics::composite($orig,$path,$opts);
|
||||||
->quality(module::get_var('gallery', 'image_quality'))
|
|
||||||
->rotate($rotation)
|
|
||||||
->save($rotpath);
|
|
||||||
|
|
||||||
gallery_graphics::composite($rotpath,$path,$opts);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->thumb_dirty = 1;
|
$item->thumb_dirty = 1;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name = "Emboss"
|
name = "Emboss"
|
||||||
description = "A different watermarking module"
|
description = "A different watermarking module"
|
||||||
version = 2
|
version = 1
|
||||||
author_name = "mikemayer67"
|
author_name = "mikemayer67"
|
||||||
author_url = "http://www.vmwishes.com"
|
author_url = "http://www.vmwishes.com"
|
||||||
info_url = "http://codex.gallery2.org/Gallery3:Modules:emboss"
|
info_url = "http://codex.gallery2.org/Gallery3:Modules:emboss"
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct script access.') ?>
|
<?php defined('SYSPATH') or die('No direct script access.') ?>
|
||||||
|
/*************************************************************************
|
||||||
<!--
|
* Copyright (C) 2012 Michel A. Mayer *
|
||||||
Copyright (C) 2012 Michel A. Mayer
|
* *
|
||||||
|
* This program is free software: you can redistribute it and/or modify *
|
||||||
This program is free software: you can redistribute it and/or modify
|
* it under the terms of the GNU General Public License as published by *
|
||||||
it under the terms of the GNU General Public License as published by
|
* the Free Software Foundation, either version 3 of the License, or *
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* (at your option) any later version. *
|
||||||
(at your option) any later version.
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
This program is distributed in the hope that it will be useful,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* GNU General Public License for more details. *
|
||||||
GNU General Public License for more details.
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
You should have received a copy of the GNU General Public License
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
*************************************************************************/
|
||||||
-->
|
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
function checkAllOverlays()
|
function checkAllOverlays()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user