User:Nichalp/Upload script
This page requires updating because: not working? fails to log-in In doing so, you could add a timestamp to the page.
|
Nichalp's upload script | |
Script information | |
---|---|
Author | Nichalp |
Talk | Talk |
Main page | Upload script |
Language | Perl |
Version | 1.0 + 1.3.1 |
Description | Automates mass uploading of images with metadata |
Licence | GPLv3 |
Formats supported | JPG/JPEG |
Scripts | |
Scripts | |
Help files | |
Running the script | Main page |
Installation | Installation |
Spreadsheet information | csv fields explained |
CSV example | upload.csv |
Spreadsheet tips | Spreadsheet tips |
Nichalp's Upload Script is a script written in Perl that helps you upload your photographs en masse to commons. Instead of manually adding a description, the date, categories, licence information, and geo-templates to each image, you can write it just once, and the script will format it as wiki-syntax for the entire series of images you want to upload. This is particularly useful if you have to fill in similar information for a series of images. But that's not all! You can do so much more.
The script can be used on Microsoft Windows and GNU/Linux. It has not been tested on Mac. If you have a fast internet connection, or plan to upload smaller files, consider getting a bot account to prevent the script from flooding the recent changes list.
Features edit
- Rename the images on-the-fly.
- Rotate images on-the-fly.
- Autoformat wiki-syntax, so you do not have to worry about template parameters.
- Embeds your name, caption, and GPS data in the Exif information.
- Add descriptions in several languages.
- Adds the {{Location}} template if GPS coordinates are supplied.
- (Optional) Adds the {{Photo Information}} template
- (Optional) Adds the {{Flickr-self}} template, if you have upload the same image to Flickr.
- Creates a gallery.txt file with the list of image in wiki-syntax. This allows you to copy-paste the text into an image gallery.
- Rigorous checking to make sure that you have added a category, description, and licence to each image, and if parameters are in range.
How it works edit
There are two scripts that need to be used.
- The first script is used to scan all JPEG images in the directory, and store the information such as date, camera information and so on into a CSV (comma separated value) file. The image names and column headings are automatically added.
- Using any Spreadsheet software, fill up the various fields such as description, new name, category and so on.
- Run the second script to read the CSV file data, and upload the corresponding file to commons.
Disclaimers edit
- This script is largely untested for all possible permutations and combinations. Use at your own risk. See also #Bugs.
- Back up all images before uploading.
- The script will automatically upload over existing images. Make sure you check if the file name you supplied does not exist in commons.
- The script does not check if you have renamed the file correctly. Beware of introducing duplicate file names when renaming.
- By default, your commons password is visible on the monitor when asked to enter it. To hide it use:
perl upload.pl - secure
- This script is currently limited to uploading only self-created photographs in JPG/JPEG format. Support for other formats coming soon.
Essentials edit
You must have the following installed to run the scripts:
- Perl
- ExifTool library
- Text:CSV parser library
- libjpeg.
Read the installation guide to install the above for Microsoft Windows or Linux.
Executing the script edit
- Create a new folder.
- Copy the images you want to upload into the above folder.
- Copy the perl scripts: csv_creator.pl and upload.pl into the folder.
- In the command line (Terminal in Linux/DOS in Windows), navigate to the above folder.
- Run csv_creator.pl from the command line by typing:
perl csv_creator.pl
- A CSV (comma separated value) file, upload.csv is created in the folder. The CSV file includes the header line, the list of image file names in the folder, and the corresponding image Exif information.
- Add the necessary information you want to the CSV file. To know how to format data in the CSV file, please read CSV fields explained. You can edit the data in your favourite spreadsheet software such as LibreOffice Calc or Microsoft Office Excel.
- Save the CSV file.
- Run upload.pl from the command line by typing:
perl upload.pl
- To specify your CSV file location, use
perl upload.pl file.csv
- To hide your password while typing it, use
perl upload.pl - secure
- To tell Perl to not load huge images/files into memory, but read them directly from disk while uploading, use
perl upload.pl - - disk
- If your CSV file does contain any UTF-8 (non-ASCII) characters, use
perl upload.pl - - - utf8
- To specify your CSV file location, use
- You are then asked to enter your username and password.
- The script then uploads the image along with the associated metadata. Errors if any, are logged in debug.txt.
- A gallery.txt file is created in the same folder. This file contains the list of images marked up with the gallery wiki syntax. If you need, you can use the text to create image galleries.
Bugs edit
- The last version will give a strange declaration error concerning $csv. See User talk:Nichalp/Upload script for a fix.
- Enabling it for different file types like .png is possible. See User talk:Nichalp/Upload script.
- Using permission "1" or "7" will result in unwanted outcomes. See User talk:Nichalp/Upload script for a fix.
- May hang if the computer is unattended for a long time. Solution: Check the last file uploaded. Quit the program, open the CSV file, delete all entries up to the last uploaded file. And restart the process.
- HTML formatting may appear in the command prompt. Reason unclear. Possible solution: Avoid editing in commons when uploading.
Credits edit
- User:Eloquence (Erik Möller) for Commons:File upload service/Script, which I used to hack and cannibalise.
- Phil Harvey, author of ExifTool for his wonderful script and help provided.