Announcement

#46 2015-03-13 13:43:58

wsloand
Member
2014-11-17
31

Re: Raw File SUpport

plg wrote:

wsloand wrote:

(I'm a new dad!  Grandparents want pictures!)

Congrats. This is a bit why Piwigo was designed at the beginning ;-)

Thank you!

plg wrote:

If you want I can write the core handlers, then you can create a plugin for another handler (or several handlers, if it's relevant to group them)

Thank you, that would be very helpful.  If you can show one example of how you'd like it to work, I'm happy to implement all the other handlers and write up documentation on how to write more.

Offline

 

#47 2015-05-11 05:20:35

wsloand
Member
2014-11-17
31

Re: Raw File SUpport

I just updated the diff in the bug report (http://piwigo.org/bugs/view.php?id=3182).  I think it matches the suggestions previously made for updating the style.  Can @plg and @mistic100 please take a look?

Offline

 

#48 2015-05-28 13:54:27

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

Re: Raw File SUpport

Hi wsloand,

I'm working on your patch.

Some files are obviously missing. For example functions {default_conf, get_upload_exts, register_upload_file_ext} are unknown :-/

I have removed some changes from your diff (for example install.php, which is not related to the "any file upload" issue).

The code looks fine, but right now I can't test it due to missing files.

Offline

 

#49 2015-05-28 14:04:35

wsloand
Member
2014-11-17
31

Re: Raw File SUpport

Thank you for looking at it!

I missed one file that I added in my diff.  I just uploaded a new version into the bug including representative_gen.php.

Offline

 

#50 2015-05-28 14:24:03

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

Re: Raw File SUpport

Thank you for adding admin/include/representative_gen.php I understand better how this works now.

Plugin "UploadAnyFile" is actually not a plugin. Not the way it is implemented. You have no main.inc.php (which is the very first file to have in a plugin) and Piwigo core searches in "UploadAnyFile" (admin/include/representative_gen.php) :

Code:

for foreach (glob(PHPWG_ROOT_PATH.'plugins/UploadAnyFile/*.php') as $filename)

so it means Piwigo core relies on a plugin, which is forbidden: a plugin can be installed/activate/deactivated/removed without breaking Piwigo core.

I don't think we need several triggers upload_file_tiff, upload_file_mpg, etc. Only one trigger should be enough I think.

I'm going to work from your patch and make it more compliant with the way Piwigo works :-) Anyway, good job! this is not an easy part ;-)

Offline

 

#51 2015-05-29 04:24:00

wsloand
Member
2014-11-17
31

Re: Raw File SUpport

I recognized that UploadAnyFile wasn't exactly a plugin, but I didn't quite know what to do to make it fit in with the general structure.  Also, I tried to figure out a way to make it work with one trigger, but I couldn't determine a fallback method within a file extension so that if, for example, conversion method 1 for tiff didn't work, it would try conversion method 2.

Thank you for taking it the last steps to integration!

Offline

 

#52 2015-05-29 12:45:16

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

Re: Raw File SUpport

Here is an example of handler for PDF files:

Code:

add_event_handler('upload_file', 'uaf_pdf');
function uaf_pdf($representative_ext, $file_path)
{
  global $logger, $conf;
  
  $logger->info(__FUNCTION__.', $file_path = '.$file_path.', $representative_ext = '.$representative_ext);
  
  if (isset($representative_ext))
  {
    return $representative_ext;
  }

  if (pwg_image::get_library() != 'ext_imagick')
  {
    return $representative_ext;
  }

  if (!in_array(strtolower(get_extension($file_path)), array('pdf')))
  {
    return $representative_ext;
  }
  
  $ext = default_conf('pdf_representative_ext', 'jpg');
  $jpg_quality = default_conf('pdf_jpg_quality', 90);
  
  // move the uploaded file to pwg_representative sub-directory
  $representative_file_path = original_to_representative($file_path, $ext);
  prepare_directory(dirname($representative_file_path));
    
  $exec = $conf['ext_imagick_dir'].'convert';
  if ('jpg' == $ext)
  {
    $exec.= ' -quality '.$jpg_quality;
  }
  $exec.= ' "'.realpath($file_path).'"[0]';
  $exec.= ' "'.$representative_file_path.'"';
  $exec.= ' 2>&1';
  @exec($exec, $returnarray);
  
  // Return the extension (if successful) or false (if failed)
  if (file_exists($representative_file_path))
  {
    $representative_ext = $ext;
  }

  return $representative_ext;
}

"uaf" stands for UploadAnyFile, but actually I think this handler should stay in Piwigo core and I also think the plugin should be "RAW support" with only a handler for RAW files.

Offline

 

#53 2015-05-29 14:10:39

xbgmsharp
Member
1970-01-01
215

Re: Raw File SUpport

Hello,

I believe we need an plugin mechanism on the upload method to support new format and feature.
For VideoJS, I had a few feature request to handle the movie frame as well as time selection to generate the poster, see [Github] piwigo-videojs issue #57 for reference.
Those features are not available in the current upload method.
Also the supported file format is not exactly the same, http://piwigo.org/bugs/view.php?id=3217
To avoid duplicate code, a call to the plugin would be preferable.
Another request that came out was an API call for the VideoJS sync method.

Thanks for considering.

Offline

 

#54 2015-05-29 21:53:22

CircleB
Guest

Re: Raw File SUpport

Will this work with .NEF files?

 

#55 2015-05-30 17:31:51

circleb
Member
2015-05-30
2

Re: Raw File SUpport

I tried to install this on my local testing installation by running these commands:

Code:

$ cd /path/to/my/install

Code:

$ patch -p0 < /downloads/piwigo_raw-0.1-2.diff

This is what was returned:

Code:

patching file admin/include/functions_upload.inc.php
patching file admin/include/upload_representative_gen.php
patching file plugins/upload_helpers/dcraw.php
patching file plugins/upload_helpers/ffmpeg.php
patching file plugins/upload_helpers/imagemagick_pdf.php
patching file plugins/upload_helpers/imagemagick_tiff.php

But every time I try to upload (by going to "Photos->Add") a .CR2 or .NEF I get an alert that says it's not a supported extension.

Last edited by circleb (2015-05-30 17:32:20)

Offline

 

#56 2015-06-16 17:11:49

circleb
Member
2015-05-30
2

Re: Raw File SUpport

Does anyone have any idea why this isn't working for me?

Offline

 

#57 2015-06-18 13:01:41

wsloand
Member
2014-11-17
31

Re: Raw File SUpport

Hi circleb,

Do you see NEF or CR2 listed in the acceptable list of file extensions when uploading?

Last edited by wsloand (2015-06-18 13:01:55)

Offline

 

#58 2015-08-05 06:13:24

Anndrew
Guest

Re: Raw File SUpport

Raw support is working for me using this patch. Great!

Is it close to becoming a plugin or are there some problems that need to be fixed?

Great addition to Piwigo!

 

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact