•  » Engine
  •  » [multisize] cleaning the database

#1 2012-01-12 13:11:56

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13963

[multisize] cleaning the database

Hi rvelices,

piwigo_images.width
piwigo_images.height
piwigo_images.filesize
piwigo_images.high_width
piwigo_images.high_height
piwigo_images.high_filesize

I believe we don't need these columns any longer. Do you confirm?

Maybe we should only keep piwigo_images.filesize and update it with the value of piwigo_images.high_filesize before removal.

Offline

 

#2 2012-01-12 13:58:34

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] cleaning the database

We absolutely need:

piwigo_images.width
piwigo_images.height

They are used for
- computing the derivative size
- choose an appropriate smaller derivative or the original. The algo is still incompletely implemented but suppose that you have an orginal situated somewhere between medium and large:

Code:

if we need rotation or watermarking then
  large will be large (but no scaling); xlarge and xxlarge will map to large
else
  large, xlarge and xxlarge will map to the original (SAME_AS_SRC in the code)

Concerning the .filesize, yes we can keep it ...

And by the way because I hate too many xxx-database.php, would you mind adding:

Code:

'ALTER TABLE '.USER_INFOS_TABLE.' DROP COLUMN maxwidth, DROP COLUMN maxheight'
'ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN coi varchar(4) DEFAULT NULL COMMENT \'center of interest\' AFTER width'

Offline

 

#3 2012-01-12 14:07:01

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13963

Re: [multisize] cleaning the database

Fine. So I keep {width, height, filesize}

We have to discuss about the default values for dimensions on sizes. In my opinion they are too small. And maybe that with larger dimensions, your algorithm needs an update also.

Offline

 

#4 2012-01-12 16:02:57

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] cleaning the database

plg wrote:

We have to discuss about the default values for dimensions on sizes. In my opinion they are too small.

what about
small 288 x 288
medium 504 x 504
large 864 x 648 or 936 x 648
xlarge 1224 x 864
xxlarge 1536 x 1080
(note always multiple of 72)

plg wrote:

And maybe that with larger dimensions, your algorithm needs an update also.

Which algo you are talking about ? The one above ? What update ?

Offline

 

#5 2012-01-12 17:28:17

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13963

Re: [multisize] cleaning the database

How do I convert:

-INSERT INTO piwigo_config (param,value) VALUES ('upload_form_thumb_maxwidth','150');
-INSERT INTO piwigo_config (param,value) VALUES ('upload_form_thumb_maxheight','150');
-INSERT INTO piwigo_config (param,value) VALUES ('upload_form_thumb_quality','95');
-INSERT INTO piwigo_config (param,value) VALUES ('upload_form_thumb_crop','true');
-INSERT INTO piwigo_config (param,value) VALUES ('upload_form_thumb_follow_orientation','true');

into $conf['derivatives']?

Offline

 

#6 2012-01-12 18:34:40

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] cleaning the database

ImageStdParams::make_default();
$types = ImageStdParams::get_defined_type_map();

$size = array($conf['upload_form_thumb_maxwidth'], $conf['upload_form_thumb_maxheight'])
$thumb = new DerivativeParams(
  new SizingParams( $size, $conf['upload_form_thumb_crop'] ? 1 : 0, $conf['upload_form_thumb_crop'] ? $size : null)
  );
$thumb->quality = $conf['upload_form_thumb_quality'];
$types[IMG_THUMB] = $thumb;
// same for websize -> large
// todo (painful) make sure ideal size of thumb/large is between square-small/medium-xlarge
ImageStdParams::set_and_save( $types );

follow_orienation cannot be put here - it's going to be complicated see my post [Forum, post 126678 by rvelices in topic 18570] Multiple-size

Offline

 

#7 2012-01-12 20:57:33

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13963

Re: [multisize] cleaning the database

OK, thank you for the example.

1) I think we should not care about the web size from Piwigo 2.3. In Piwigo 2.4, we'll have 5 web sizes (from S to XXL)

2) my question was really about the follow orientation option, I've opened a topic about [Forum, topic 18658] [multisize] rotation

Offline

 

#8 2012-01-12 21:59:49

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13963

Re: [multisize] cleaning the database

I would like to commit things I have added today but I would also like to have a clean upgrade on follow_orientation, so I'll first commit the new parameters original_resize* and I'll see later about removal of obsolete parameters.

Offline

 

#9 2012-01-13 08:59:22

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [multisize] cleaning the database

#images.tn_ext should also be removed from db

Offline

 

#10 2012-05-21 21:44:05

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13963

Re: [multisize] cleaning the database

I'm working on the upgrade script. The one that moves the 2.3 HD into 2.4 original. As long as Piwigo doesn't perform any "copy" but only "move", the script runs pretty fast: 500ms for 10k HD photos.

To avoid any problem during upgrade, I will provide the operation "remove pwg_high and thumbnail directories" in a separate plugin. This operation can be long, depending on the disk performances. I don't want to take the risk to fail an upgrade for a non blocking operation (keeping the "thumbnail" directories in "upload" is not a problem)

In addition to moving (overwritting) files, the script updates the images.width, images.height and images.filesize based on images.high_width, images.high_height and images.high_filesize (which are removed).

Code:

$upgrade_description = 'derivatives: new organization of "upload" and "galleries" directories';

$query = '
SELECT
    id,
    path,
    tn_ext,
    has_high,
    high_filesize,
    high_width,
    high_height
  FROM '.IMAGES_TABLE.'
;';
$result = pwg_query($query);
$starttime = get_moment();

$updates = array();

while ($row = pwg_db_fetch_assoc($result))
{
  if ('true' == $row['has_high'])
  {
    $high_path = dirname($row['path']).'/pwg_high/'.basename($row['path']);
    rename($high_path, $row['path']);

    array_push(
      $updates,
      array(
        'id' => $row['id'],
        'width' => $row['high_width'],
        'height' => $row['high_height'],
        'filesize' => $row['high_filesize'],
        )
      );
  }
}

$endtime = get_moment();
$elapsed = ($endtime - $starttime);
echo sprintf('%.3fs to move HD', $elapsed);

if (count($updates) > 0)
{
  mass_updates(
    IMAGES_TABLE,
    array(
      'primary' => array('id'),
      'update' => array('width', 'height', 'filesize'),
      ),
    $updates
    );
}

Remaining operations are :

* removing columns images.high_width, images.high_height, images.high_filesize, images.tn_ext, images.has_high, user_infos.maxwidth, user_infos.maxheight
* converting 2.3 thumbnails/websize settings into 2.4 derivatives settings
* update upgrade task 113 to convert config params upload_form_hd* into original_resize*
* removing configuration parameters upload_form* (14 parameters)

Offline

 

#11 2012-05-21 21:56:12

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13963

Re: [multisize] cleaning the database

edit on previous post: and also remove images.has_high

Offline

 

#12 2012-05-31 16:15:00

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13963

Re: [multisize] cleaning the database

[Bugtracker] ticket 2632

* 122-database.php organizes "galleries" and "upload" folders
* 123-database.php converts Piwigo 2.3 resize settings into Piwigo 2.4 derivatives settings
* 124-database.php cleans the database (configuration settings and table columns)

Offline

 

#13 2012-05-31 19:30:26

flop25
Piwigo Team
2006-07-06
7037

Re: [multisize] cleaning the database

there might be a problem about cropping : the size for thumbnails were successfully imported but thumbnails become cropped
Someone reproduce ?


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#14 2012-05-31 20:44:10

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13963

Re: [multisize] cleaning the database

flop25 wrote:

there might be a problem about cropping : the size for thumbnails were successfully imported but thumbnails become cropped

Do you have a backup of your database? can you perform a:

Code:

select param, value from piwigo_config where param like 'upload_form%';

Offline

 
  •  » Engine
  •  » [multisize] cleaning the database

Board footer

Powered by FluxBB

github linkedin newsletter Piwigo.org © 2002-2025 · Contact