Changeset 2670


Ignore:
Timestamp:
Oct 5, 2008, 11:22:57 PM (16 years ago)
Author:
plg
Message:

feature 885 added: pwg.images.add web API method now supports additional
high resolution format.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_functions.inc.php

    r2644 r2670  
    951951  $dumped_md5 = md5_file($file_path);
    952952  if ($dumped_md5 != $params['file_sum']) {
    953     return new PwgError(500, 'file transfert failed');
     953    return new PwgError(500, 'file transfer failed');
    954954  }
    955955
     
    981981  $dumped_md5 = md5_file($thumbnail_path);
    982982  if ($dumped_md5 != $params['thumbnail_sum']) {
    983     return new PwgError(500, 'thumbnail transfert failed');
    984   }
    985 
    986   // fwrite($fh_log, 'output: '.md5_file($file_path)."\n");
    987   // fwrite($fh_log, 'output: '.md5_file($thumbnail_path)."\n");
     983    return new PwgError(500, 'thumbnail transfer failed');
     984  }
     985
     986  // high resolution
     987  if (isset($params['high_content']))
     988  {
     989    // high resolution directory is a subdirectory of the photo file, hard
     990    // coded "pwg_high"
     991    $high_dir = $upload_dir.'/pwg_high';
     992    if (!is_dir($high_dir)) {
     993      umask(0000);
     994      mkdir($high_dir, 0777);
     995    }
     996
     997    // high resolution path, same name as web size file
     998    $high_path = sprintf(
     999      '%s/%s.%s',
     1000      $high_dir,
     1001      $filename_wo_ext,
     1002      'jpg'
     1003      );
     1004
     1005    // dump the high resolution file
     1006    $fh_high = fopen($high_path, 'w');
     1007    fwrite($fh_high, base64_decode($params['high_content']));
     1008    fclose($fh_high);
     1009    chmod($high_path, 0644);
     1010
     1011    // check dumped thumbnail md5
     1012    $dumped_md5 = md5_file($high_path);
     1013    if ($dumped_md5 != $params['high_sum']) {
     1014      return new PwgError(500, 'high resolution transfer failed');
     1015    }
     1016
     1017    $high_filesize = floor(filesize($high_path)/1024);
     1018  }
    9881019
    9891020  list($width, $height) = getimagesize($file_path);
     
    10161047      $insert[$key] = $params[$key];
    10171048    }
     1049  }
     1050
     1051  if (isset($params['high_content']))
     1052  {
     1053    $insert['has_high'] = 'true';
     1054    $insert['high_filesize'] = $high_filesize;
    10181055  }
    10191056
  • trunk/tools/piwigo_remote.pl

    r2634 r2670  
    77use LWP::UserAgent;
    88use Getopt::Long;
     9use Encode qw/is_utf8 decode/;
    910
    1011my %opt = ();
    1112GetOptions(
    1213    \%opt,
    13     qw/action=s file=s thumbnail=s categories=s define=s%/
     14    qw/action=s file=s thumbnail=s high=s categories=s define=s%/
    1415);
    1516
     
    6263        categories => $opt{categories},
    6364    };
     65
     66    if (defined $opt{high}) {
     67        $form->{high_content} = encode_base64(read_file($opt{high}));
     68        $form->{high_sum} = file_md5_hex($opt{high});
     69    }
    6470
    6571    foreach my $key (keys %{ $opt{define} }) {
  • trunk/ws.php

    r2634 r2670  
    181181      'thumbnail_content' => array(),
    182182      'thumbnail_sum' => array(),
     183      'high_content' => array('default' => null),
     184      'high_sum' => array('default' => null),
    183185      'name' => array('default' => null),
    184186      'author' => array('default' => null),
Note: See TracChangeset for help on using the changeset viewer.