• Hi,

    I am trying to get to grips with the .csv import. Could you put some example albums with the corresponding .csv files onto https://wppa.nl/ ?

    I am trying to import 12000 Albums. I have the .jpgs in folders (one folder per album, max 11 photos per album). Each folder has a text file which has the following structure:

    Full User Name
    User@email
    Album Title eg: Album of trackday
    Date of Album eg: “Jul 25 2002 17:08:07”
    Name of this album upload folder eg: 1027616887
    Filename first photo eg: 1~1027616887.jpg
    Comment first photo eg: The racer at Watkins Glen last month with a ton of BMWs
    Filename second photo eg: 2~1027616887.jpg
    Comment first photo eg: Aluminum Ski Slope with all the buttons removed. I wanted a vintage race car look.

    and so on until the final photo
    eg:
    7~1027616887.jpg
    First point of impact. I\’ll try to save the 1/4 and just replace the lens and bumpers.

    Do I need to make one .csv for all the uploads, or can I autocreate the albums from individual .csv files within each upload folder?

Viewing 10 replies - 16 through 25 (of 25 total)
  • Thread Starter jagwaugh

    (@jagwaugh)

    I am running two test machines to get familiar with wppa. One is on a Synology Nas, the other is an Amazon EC2 Instance. It’s just a VM running Ubuntu 16.04. The free tier VMs are single vCPU and 1G, which is what I started with, but I then upgraded it to a 2G instance (which only costs a little to run, and I can downgrade it back to the smaller size if I want).

    As to the background process skip, here is what I am trying to do:

    I need to migrate all of the photo albums from https://www.jag-lovers.org/snaps/ to our new WordPress site (www.jag-lovers.com).

    The Albums are organised in a tree, with a separate branch for each “category” (model of Jaguar).

    Each Album has:

    a description
    max 12 images each with it’s own comment
    Albums have Owners names, emails, and the date they were originally posted

    This information I have in .csv files.

    Fortunately, the image filenames are based on the gnutime the album was uploaded, so I have:

    album 1199679324
    containing images:
    1~1199679324.jpg

    12~1199679324.jpg

    So the filenames are all unique.

    At the moment I am just working on getting the files, structure, and original information (Comment, username, email, time) into wppa.

    Now I have a decent sized sample (about 5000 albums) on my test machine I can look at setting up the search pages and figure out how to handle new albums.

    The background processes don’t make a difference when a user (or three) are uploading a new album, but during the import process they were a bit of a bother. A “Migrate mode” might be worth thinking about.

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    Got it working in the current beta version.
    See https://wppa.nl/docs-by-subject/development-version/ on how to install. This is safe to do.
    When installed, see Table VIII-A0.2
    This skips all wppa background processing and will auto reschedule them when switched off.

    Thread Starter jagwaugh

    (@jagwaugh)

    Great!,

    I’ll try it the next time I run an upload.

    Thread Starter jagwaugh

    (@jagwaugh)

    Sorry for the late reply. it works fine so I’ll mark this as closed.

    Hi Jacob,

    Congratulation for your plugin. I’m testing for to use in our project and certainly we will do a donate, because your plugin it’s very good.
    I have a system that was build in php/mysql and I intend to import 8000 photos for the “WP Photo Album Plus” plugin.
    I have an information in this system that is the size of impress (ExifImageWidth / ExifResolution (dpi) = value in inches) that I have to import too. The same for the ExifImageHeight.
    I created a new field for this in Table II-J10.x.
    How can I to configure CSV file for to import this photos with this information?

    Thank you!

    Regards,

    Omar Teles
    Brazil

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    Importing custom data by .csv is not a good idea. It is too tricky, the data is a serialized array and the data must be sanitized. Apart from the work you will have to prepare the .csv file, importing custom data fields using the simple version of the .csv file is disabled.

    I have a much better idea to enter the desired data into the custom data field.

    I assume you save exif/iptc data during import/upload photos (Table IX-H7 and 8).

    After importing/uploading all photos, you can run a customized procedure on all photos in Table VIII-B99.

    I will be pleased to help you writing this procedure. Just mail me a few photos that hold the exif info you need, and tell me what the result should be in which of the 10 custom data fields and i will supply you the procedure within 24 hours.

    Mail me at: opajaap at opajaap dot nl

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    I did some coding.

    I made the following assuptions:

    • ExifImageWidth = tag 0xA002
    • ExifImageHeight = tag 0xA003
    • x resolution = tag 0x011A
    • y resolution = tag 0x011B
    • Resolution unit = tag 0x0128
    • You want text like: 6.33 in. for 6.33 inch and 12.50 cm. for 12.5 centimetres.</l>

    If all of the above assumptions are correct, copy/paste the following code into the edit area in Table VIII-B99; click outside the edit area and wait for the green checkmark; then press the Start! button.

    If one or more of the assumptions i made are incorrect and you are unable to change the code, please let me know what you want to be different; then i will change the code accordingly.

    Code for Table VIII-B99:

    <?php
    // Find the image width and height
    $exif_width  = $wpdb->get_var( "SELECT description FROM " . WPPA_EXIF . " WHERE tag = 'E#A002' AND photo = " . $id );
    $exif_height = $wpdb->get_var( "SELECT description FROM " . WPPA_EXIF . " WHERE tag = 'E#A003' AND photo = " . $id );
    
    // Find the image x resolution
    $x_res = $wpdb->get_var( "SELECT description FROM " . WPPA_EXIF . " WHERE tag = 'E#011A' AND photo = " . $id );
    $x_res = explode( '/', $x_res );
    if ( isset( $x_res[1] ) && $x_res[1] > 0 ) {
        $x_res = $x_res[0] / $x_res[1];
    }
    else {
        $x_res = $x_res[0];
    }
    
    // Compute the width in res units
    $x_result = $x_res ? sprintf( "%1.2f", $exif_width / $x_res ) : '';
    
    // Find the image y resolution
    $y_res = $wpdb->get_var( "SELECT description FROM " . WPPA_EXIF . " WHERE tag = 'E#011B' AND photo = " . $id );
    $y_res = explode( '/', $y_res );
    if ( isset( $y_res[1] ) && $y_res[1] > 0 ) {
        $y_res = $y_res[0] / $y_res[1];
    }
    else {
        $y_res = $y_res[0];
    }
    
    // Compute the height in res units
    $y_result = $y_res ? sprintf( "%1.2f", $exif_height / $y_res ) : '';
    
    // Find the resolution unit ( inch/cm/undefined )
    $res_unit = $wpdb->get_var( "SELECT description FROM " . WPPA_EXIF . " WHERE tag = 'E#0128' AND photo = " . $id );
    
    switch ( $res_unit ) {
        case '2':
    		$x_result .= ' in.';
    		$y_result .= ' in.';
    		break;
        case '3':
    		$x_result .= ' cm.';
    		$y_result .= ' cm.';
    		break;
    }
    
    // Get existing custom data fields
    $cust_fields = unserialize( wppa_get_photo_item( $id, 'custom' ) );
    
    // Update
    $cust_fields[0] = wppa_sanitize_custom_field( $x_result );
    $cust_fields[1] = wppa_sanitize_custom_field( $y_result );
    wppa_update_photo( array( 'id' => $id, 'custom' => serialize( $cust_fields ) ) );
    

    Important notice: The code starts with <?php but does not end in ?>. This is correct.

    I have put this code as example 2 on this documentation page

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    Please ignore this:

    Importing custom data by .csv is not a good idea. It is too tricky, the data is a serialized array and the data must be sanitized. Apart from the work you will have to prepare the .csv file, importing custom data fields using the simple version of the .csv file is disabled.

    I just ment:

    The work you will have to do to prepare the .csv file starting from the exif data can easily be done by wppa itsself.

    Hello Jacob,

    Thank you very much for the code. I tested and had success. I did a little change that was to convert inch to centimeters when the unit is inch, because in Brazil it’s common to use centimeters instead inches.

    I will continue testing your plugin and if I have some doubt I will sent for you it.

    Omar

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    Nice to hear my code does what you need.
    To prevent possible undefined index warnings in the future, i recommend you to add a few lines and run the proc again. This is to meet the softwares assumption that the custom field is either empty or a serialized array of 10 elements.
    please change:

    // Get existing custom data fields
    $cust_fields = unserialize( wppa_get_photo_item( $id, 'custom' ) );
    

    into:

    // Get existing custom data fields
    $cust_fields = unserialize( wppa_get_photo_item( $id, 'custom' ) );
    for ( $i=0; $i<10; $i++ ) {
        if ( ! isset( $cust_fields[$i] ) ) {
            $cust_fields[$i] = '';
        }
    }
    

    It has been tested end does the job.

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘CSV import’ is closed to new replies.