How to set up R 'exifr' package with Strawberry Perl (Use gmake!!!)

Started by Stan Wickham, July 12, 2019, 07:54:13 AM

Previous topic - Next topic

Stan Wickham

Initial setup of Perl and exiftool for use with the R 'exifr' package took many hours (reading forums) when setup should have taken minutes.

Mistakes were made when I :


       
  • Copied 'exiftool.pl' and '.\lib' to 'C:\Windows\exiftool'.

    •       
    • 'C:\Windows' is in the Path.
    • Subdirectories of 'C:\Windows' are not in the Path.
    • SOLUTION: moved 'exiftool.pl' and '.\lib' to 'C:\Windows'.
  • Couldn't get the R package 'exifr' to load after placing exiftool.pl' and '.\lib' in 'C:\Windows'.

    •       
    • As of July 2019, exiftool is the only command that 'exifr' looks for in the Path.
    • 'exifr' does not look for exiftool.pl in the Path.
    • 'exifr' does not look for exiftool.pl in 'C:\Windows'.
    • 'exifr' does check the 'exifr.exiftoolcommand' option, which is not normally set when 'exifr' loads.
    • SOLUTION: Set 'exifr.exiftoolcommand' option to the filepath of 'exiftool.pl' in an '.Rprofile' file.
    • EXAMPLE: options(exifr.exiftoolcommand="C:\\Windows\\exiftool.pl")
    • Save a copy of this '.Rprofile' file to each RStudio Project directory for which 'exifr' is required.

    •    
  • Tried to build Image::ExifTool using make command.

    •       
    • make might be in the Path for my configuration of Windows 10.
    • make, make test, and make install appear to do something, but do not build Image::ExifTool.
    • SOLUTION: Replace make with gmake in each of the above.

How to Configure System for R exifr Using Strawberry Perl on Windows 10

       
  • Download Strawberry Perl and install to a directory without any spaces in filepath.
       I accepted the default 'C:\Strawberry' option.
  • Confirm Perl installation by opening a Command Prompt and typing the command perl --version.
  • Download the platform-independent Perl library from ExifTool homepage. Currently the file is "Image-ExifTool-11.54.tar.gz".
  • Extract the library. Command line options (gnu tar?) exist and WinZip works. I used 7-zip.
  • Rename 'exiftool' to 'exiftool.pl' and copy along with the '\lib' directory to 'C:\Windows'. This requires Admin permissions.
          Or, create a new directory (no spaces in path to be careful) and add the directory to the System Path environment variable.
  • Confirm that 'exiftool.pl' is available on the Path by opening a Command Prompt, typing exiftool.pl -ver and hitting Enter.
          The version number should display on the next line.
  • Install R package 'exifr' with install.packages("exifr").
  • Test package with library(exifr).
  • If 'exifr' fails to load, tell it where 'exiftool.pl' is located using an '.Rprofile' file saved to the RStudio Project folders for which 'exifr' is required. For example,
          options(exifr.exiftoolcommand="C:\\Windows\\exiftool.pl") points 'exifr' to 'C:\Windows'.
  • Close and restart RStudio by opening the Project file (.Rproj) in the Project. R will check the '.Rprofile' file as it launches.
  • getOption("exifr.exiftoolcommand") should report the value set in '.Rprofile'.
  • library(exifr) should successfully load 'exifr'. If not, check getOption("exifr.exiftoolcommand") and getOption("exifr.perlpath") again.
  • To make 'exiftool' available in Perl, build the 'Image::ExifTool' module. The frequently recommended sequence of commands at the Command Prompt:
          
             perl Makefile.PL
             make
             make test
             make install
          

          appeared to do something, but the command exiftool -ver failed and cpan -l (list of installed modules) did not include any 'Image::ExifTool::<>' entries.
          
  • Perl forums suggested dmake or nmake when make was not available or didn't work on Windows.
          Strawberry Perl 5.30.0.1 warns that 'dmake' is no longer part of Strawberry Perl and suggests gmake.
  • Using gmake in the above sequence works.
          
             perl Makefile.PL
             gmake
             gmake test
             gmake install
          
       
       Steps taken by each of the commands spill across the screen.
  • Before building 'Image::ExifTool', exiftool.pl invoked exiftool, but exiftool yielded the error message
          "'exiftool' is not recognized as an internal or external command, operable program or batch file."
  • After building 'Image::ExifTool', exiftool also invokes exiftool.
  • After building 'Image::ExifTool', I have removed 'exiftool.pl' and the associated '\lib' directory from the Path,
          which disables exiftool.pl.
  • Despite this, 'exifr' continues to load (it finds exiftool on the command line at 'exiftool').

I will soon find out if I can rely on the built-for-Perl, Image::ExifTool derived [exiftool on the command line and in R, or
if I will need to return 'exiftool.pl' and '\lib' to the Path. Now on to actually learning to use exiftool.

Phil Harvey

Note that it is not necessary to build ExifTool, so the entire "make" process may be skipped as long as you unpack the distribution and place "exiftool" and its "lib" directory together somewhere in the path.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

obetz

There are several issues:

The whole process described by Stan is way too complicated. You can't expect a normal user to do that!

C:\Windows is not a suitable place to install ExifTool (or any other non-Windows component). Stan: Can you tell me who suggested to use c:\windows?

Just unpacking ExifTool together with a Perl distribution doesn't need to be sufficient since it rather likely lacks Perl modules. For example, Win32::FindFile is usually not contained. And due to a long known unfixed error in the Win32::FindFile tests, installation will fail if you are in a DST time zone.

I don't know whether exifr runs with the packed exiftool.exe, otherwise this would be another candidate to use the Windows package I prepared (ExifTool with a specifically wrapped Strawberry Perl).

Oliver

Stan Wickham

Some brief followup on my initial post:

13. Failure of attempt to build the 'Image::ExifTool' module using make command.

where make returned C:\Rtools\bin\make.exe. I had a version of make, but not the version that mattered here.


An important note for R users (especially if your Perl install uses 'make.exe'):

       
  • Rtools (Windows toolset) includes a build of GNU Make 4.2.1 (Built for i686-pc-msys), invoked by make.

    •       
    • This build, required for Rtools, was responsible for the failed 'Image::ExifTool' build.
    • Rtools is positioned first on PATH for it to work, which will override other instances of 'make.exe'.
    • (See warning in the R Admin manual.)
    • https://cran.r-project.org/doc/manuals/R-admin.html#The-command-line-tools
       
  • Strawberry Perl's build of GNU Make 4.2.1 (Built for x86_64-w64-mingw32)is invoked by the command gmake.

Stan Wickham

@obetz
I followed instructions on the Install page to place 'exiftool.pl' and associated '\lib' in "C:\WINDOWS" directory (or any other directory in your PATH)".

I had initially tried a combination of Strawberry Perl and 'exiftool.exe' in "C:\WINDOWS". (The R package 'exifr' requires Perl and exiftool). I now wonder if I did something incorrectly then. I am tempted to temporarily disable


C:\Perl\Strawberry\perl\site\bin\exiftool
C:\Perl\Strawberry\perl\site\bin\exiftool.bat


which resulted from my successful gmake-based build and copy 'exiftool.exe' to "C:\RTOOLS", which is in PATH.

Does 'exiftool.exe' include all of the Optional Dependencies noted in README? I tried to install "POSIX::strptime", which failed. I later found this (https://stackoverflow.com/questions/43195604/unable-to-install-perl-cpan-module-posixstrptime/43209147), which explained the install failure and recommended 'strptime' funtionality in "Time::Piece" and other modules.

Phil Harvey

Quote from: Stan Wickham on July 15, 2019, 07:56:26 PM
Does 'exiftool.exe' include all of the Optional Dependencies noted in README?

The distributed 'exiftool(-k).exe' does. You can do "exiftool -ver -v" for details.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

obetz

Quote from: Stan Wickham on July 15, 2019, 07:56:26 PM
@obetz
I followed instructions on the Install page to place 'exiftool.pl' and associated '\lib' in "C:\WINDOWS" directory (or any other directory in your PATH)".

This part of the installation instructions should be reworded.

If a user already has a dedicated "portable stuff"directory, this might be a good place for the standalone ExifTool.exe.

Otherwise he should create a directory for exiftool.exe and add it to the path.

Quote from: Stan Wickham on July 15, 2019, 07:56:26 PM

I had initially tried a combination of Strawberry Perl and 'exiftool.exe' in "C:\WINDOWS". (The R package 'exifr' requires Perl and exiftool). I now wonder if I did something incorrectly then.

indeed: The standalone exiftool.exe contains Perl and is not intended to be used with an installed Perl.

Quote from: Stan Wickham on July 15, 2019, 07:56:26 PM
I am tempted to temporarily disable


C:\Perl\Strawberry\perl\site\bin\exiftool
C:\Perl\Strawberry\perl\site\bin\exiftool.bat


which resulted from my successful gmake-based build and copy 'exiftool.exe' to "C:\RTOOLS", which is in PATH.

Again: exiftool.exe is an alternative to an installed Perl, not a companion. And it doesn't seem to be the right thing for exifr.

I suggest to get in contact with the exifr author to ask him for better instructions.

Oliver