Author Topic: Import von Schlüsselwörtern - Globale Namenszuweisung  (Read 19828 times)

0 Members and 1 Guest are viewing this topic.

Offline cyberworx

  • Pre-Newbie
  • Posts: 2
    • View Profile
Import von Schlüsselwörtern - Globale Namenszuweisung
« on: May 13, 2002, 08:34:15 PM »
Hallo,

ich habe eine ganze Reihe an Bildern (ca. 80.000) bei denen die Schlüsselworte mit rein müssen, praktisch wäre auch, wenn man in diesem Zug zu der Beschreibung auch noch den Namen ändern könnte.
Die Import.zip hab ich bereits versucht, gibt aber nur einen weissen Bildschirm aus, kommt praktisch über den html-Header nicht hinaus, die Inputfelder werden nicht angezeigt.
Ich hab mir die import.php angesehen und konnte den Grund hierfür nicht finden.

Wäre um Hilfe dankbar.

Gruß
Michael

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Import von Schlüsselwörtern - Globale Namenszuweisung
« Reply #1 on: May 13, 2002, 10:57:23 PM »
Hallo Michael,

das Importscript war für eine ältere Version von 4images gedacht und funktioniert mit der neuen nicht mehr. Ich habe die Datei aktualisiert und Du kannst es nochmal probieren.
http://www.4homepages.de/import.zip

Die Importdatei hat jetzt 4 Spalten, ich habe eine Spalte für den Bildnamen hinzugefügt.

Gruß Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Will wonders never cease ?!
« Reply #2 on: May 14, 2002, 06:30:24 AM »
There is an import utility for 4images?!  Excellent!

I downloaded it to try it out, unfortunately the import.txt file is in German and made it difficult for me to determine the record format.  But from looking at import.php file, is it the following?

Code: [Select]
ImageName or ImageID | Description | Keywords

How is this import used?  I get the impression that I could use "Check New Images" in the Control Panel to bulk load new images to the database, then use import.php to attach the metadata to those images.  I think I understand the category limitation and would therefore have to batch add new images to one category at a time.

I'd like to know more as I too have hundreds, perhaps thousands, of photos I want to import.

Can import.php be extended to support custom database fields using includes/db_field_definitions.php?  

Oooooh, now I'm dreaming, maybe drive import.php using a user defined template?  

    * Predefined template fields:  "4i_ImageName" (required - database primary key), "4i_Description", "4i_Keywords"
    * User defined template fields such as "Location", "Event", "FilmSpeed", "Organizer", and so on.[/list:u]

    Template Example:
    4i_ImageName | 4i_Description | 4i_Keywords | Location | FilmSpeed | Organizer

    Data File Example:
    190-12.jpg | George Heath celebrates his 500th jump | Flash GeorgeHeath | Skydive Cross Keys | ISO 400 | Team Monkey Claw

    This would be simply and unbelievably awesome for us power users.  
I would be willing to pay a nominal fee for an import utility with this much flexibility because I use Extensis Portfolio http://www.extensis.com/portfolio to track metadata and can export it easily.

Offline cyberworx

  • Pre-Newbie
  • Posts: 2
    • View Profile
Import von Schlüsselwörtern - Globale Namenszuweisung
« Reply #3 on: May 14, 2002, 08:13:56 AM »
Hallo Jan,

vielen Dank für die rasche Hilfe, funktioniert bestens.
Das spart ne Menge Arbeit.

Gruß
Michael

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Import von Schlüsselwörtern - Globale Namenszuweisung
« Reply #4 on: May 14, 2002, 11:52:58 AM »
Hi Chris,

i started to work on an import script for exported text files from Extensis Portfolio 6. Now i have to be sure that we talk from the same text files. The format of the text file i use is that all fields are separated bei Tabs and for example the Keywords are separated be strange chars like .

Do we talk from the same text files?

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Extensis Portfolio 6
« Reply #5 on: May 14, 2002, 07:07:40 PM »
Yes, I use Extensis Portfolio 6.  

For me though, I can manipulate the exported data using Excel, Access or some other tool if required to place the data in a more import friendly format.  Including the replacement of those non-printable characaters.  

From page 128 of the Portfolio 6 User Guide:
Quote

Therefore Portfolio follows the ASCII standard by using ASCII 11 as the vertical tab character.  This character will be used to denote a linebreak within a field (such as a text block like the Description field). Portfolio also uses ASCII 29 as the Group Separator character.  This character will be used to delimit values within a multi-valued field (such as the Keywords field). Some other databases that support multi-valued or multi-lined fields (such as FileMaker Pro) also support these standards.


This is probably getting ahead of things, but if the import utility was robust enough, you could probably sell it as an add-on module for 4Images.  The combined solution could actually compete easily against the Extensis Portweb plugin as that requires the user to have their own Windows server.  That just isn't affordable or practical for the vast majority of Portfolio users.

I think categories can be handled without too much effort if the "Check New Files" CP feature is used in conjunction with Portfolio's ability to "Collect" gallery images to a folder for web server upload.  A gallery collection could easily be limited to a specific Portfolio category.

If I can be of any help at all, just let me know.  As I'm sure you can tell by now, as an experienced programmer I can document issues pretty well.  Although I don't know PHP (yet) I know enough about programming in C to get around inside the code.

I'll do whatever I can to assist!  (And I'm still willing to hand over some cash to motivate you  :wink: )

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Import von Schlüsselwörtern - Globale Namenszuweisung
« Reply #6 on: May 14, 2002, 08:27:04 PM »
Hi,

in the next minutes you will receive a email with the script. I will give you now a little description how to use it.

Note: The script requires that all images are already available in your database. Maybe insert the images with "Check new images".

First extract the archive and upload the file to your admin directory.

Then export a catalog as textfile (File -> Export to Text File). I recommend you to delete the first line who describes only the field names.

Point your browser to import_portfolio6.php and you will see a table with all your database fields of the database table 4images_images. Next to each field name you will see a textinput field ("Field position in import file"). Set here the position of the data in your text file you want to import to this database field.

Example:
Code: [Select]
14.05.2002 08:05:43 image description file_name.gif Keyword1Keyword2Keyword3
If you want to update the database field image_date with "14.05.2002 08:05:43", set image_date to 1.
If you want to update the field image_keywords with "Keyword1Keyword2Keyword3", set image_keywords to 4.
If this values are always the same, you can set the default values with the array $default_positions which you will find at the top of the script.

Note: The date will be detected automatically and converted to the appropriate format. The char that separates for example the keywords will be detected and removed automatically.

Now you have to select the field you want to use as search key ("Use as search key". Sorry, my bad school english has no better word). This means the entry in the text file, the script uses to find the right database record. Damn, hard to explain  :roll: I hope you understand what i mean, if not ask me!!!!

Ok, try it and give me feedback....

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline bernd

  • Full Member
  • ***
  • Posts: 214
    • View Profile
gibt's das Import-Script noch?
« Reply #7 on: July 08, 2002, 12:15:56 AM »
Hi Jan,

unter der hier genannten URL liegt das Importscript leider nicht mehr. Wir wollen eine Bildagentur aufbauen und dafür so 2000-5000 Bilder importieren. Zum Teil liegen sie in Extensis Portfolio, die neueren verwalten wir in einer selbstgebauten FileMaker-Lösung - wär echt Klasse, wenn Du mir mal die Skripte zukommen lassen würdest (auch das für Portfolio wäre genial). Es ist richtig, daß in Deiner Lösung die Keywords nicht in einer eigenen Tabelle liegen, oder? In unserer FM-Lösung haben wir's nämlich so gemacht um eine Konsistenz zu erzwingen.

Anway, wär cool, wenn ich die Import-Dinger irgendwie kriegen könnte!

cheers,
Bernd

Offline nwpw

  • Pre-Newbie
  • Posts: 6
    • View Profile
    • http://www.nwpw.com
Data Import Script
« Reply #8 on: December 27, 2002, 07:36:30 AM »
Hi Jan,

I tried to email you about this script the other day but, I was having trouble reaching your server via HTTP so I'm not certain you received the email.

First off, I like to say Great Scripts!  Aside from some performance problems that I'm having with a large number of records, the whole package was relatively easy to install and customize.

Right now I'm specifically interested in the script that you mentioned in this thread...  I have roughly 47,000 records spread over two Portfolio 6 databases that I need to import into 4images.  I have used the batch import script to import the first 30,000 images and now I'm hoping to import the data just as smoothly...  I'm sure I can write a similar PHP script that will do the trick but it would be really nice if I didn't have to!  :)

Thanks,

Nick


Quote from: Jan
Hi,

in the next minutes you will receive a email with the script. I will give you now a little description how to use it.

Note: The script requires that all images are already available in your database. Maybe insert the images with "Check new images".

First extract the archive and upload the file to your admin directory.

Then export a catalog as textfile (File -> Export to Text File). I recommend you to delete the first line who describes only the field names.

Point your browser to import_portfolio6.php and you will see a table with all your database fields of the database table 4images_images. Next to each field name you will see a textinput field ("Field position in import file"). Set here the position of the data in your text file you want to import to this database field.

Example:
Code: [Select]
14.05.2002 08:05:43 image description file_name.gif Keyword1Keyword2Keyword3
If you want to update the database field image_date with "14.05.2002 08:05:43", set image_date to 1.
If you want to update the field image_keywords with "Keyword1Keyword2Keyword3", set image_keywords to 4.
If this values are always the same, you can set the default values with the array $default_positions which you will find at the top of the script.

Note: The date will be detected automatically and converted to the appropriate format. The char that separates for example the keywords will be detected and removed automatically.

Now you have to select the field you want to use as search key ("Use as search key". Sorry, my bad school english has no better word). This means the entry in the text file, the script uses to find the right database record. Damn, hard to explain  :roll: I hope you understand what i mean, if not ask me!!!!

Ok, try it and give me feedback....

Greets Jan

Offline nwpw

  • Pre-Newbie
  • Posts: 6
    • View Profile
    • http://www.nwpw.com
Re: Extensis Portfolio 6
« Reply #9 on: December 28, 2002, 03:22:29 AM »
Hi Chris,

How did you make out with the script that Jan emailed you in response to this post?  Do you have a copy on file?

Thanks,

Nick


Quote from: Chris
Yes, I use Extensis Portfolio 6.  

For me though, I can manipulate the exported data using Excel, Access or some other tool if required to place the data in a more import friendly format.  Including the replacement of those non-printable characaters.  

From page 128 of the Portfolio 6 User Guide:
Quote

Therefore Portfolio follows the ASCII standard by using ASCII 11 as the vertical tab character.  This character will be used to denote a linebreak within a field (such as a text block like the Description field). Portfolio also uses ASCII 29 as the Group Separator character.  This character will be used to delimit values within a multi-valued field (such as the Keywords field). Some other databases that support multi-valued or multi-lined fields (such as FileMaker Pro) also support these standards.


This is probably getting ahead of things, but if the import utility was robust enough, you could probably sell it as an add-on module for 4Images.  The combined solution could actually compete easily against the Extensis Portweb plugin as that requires the user to have their own Windows server.  That just isn't affordable or practical for the vast majority of Portfolio users.

I think categories can be handled without too much effort if the "Check New Files" CP feature is used in conjunction with Portfolio's ability to "Collect" gallery images to a folder for web server upload.  A gallery collection could easily be limited to a specific Portfolio category.

If I can be of any help at all, just let me know.  As I'm sure you can tell by now, as an experienced programmer I can document issues pretty well.  Although I don't know PHP (yet) I know enough about programming in C to get around inside the code.

I'll do whatever I can to assist!  (And I'm still willing to hand over some cash to motivate you  :wink: )

Offline nwpw

  • Pre-Newbie
  • Posts: 6
    • View Profile
    • http://www.nwpw.com
Import Script
« Reply #10 on: December 30, 2002, 10:27:20 PM »
I've been trying to use the import script posted there but, for some reason I can't seem to get the add_searchwords function to work.  I am able to update the data in the main images table using the scripts and a properly formatted text file but the script does not insert the data into the the keyword index tables...

Here's the error message I get without modifying your script:

Code: [Select]
Warning: Invalid argument supplied for foreach() in /pathto/search_utils.php on line 47

The remove_searchwords function works just fine.

I have attempted to modify the function call several ways and, although the error message goes away, the data still does not get inserted.

Thanks,

Nick



Quote from: Jan
Hallo Michael,

das Importscript war für eine ältere Version von 4images gedacht und funktioniert mit der neuen nicht mehr. Ich habe die Datei aktualisiert und Du kannst es nochmal probieren.
http://www.4homepages.de/import.zip

Die Importdatei hat jetzt 4 Spalten, ich habe eine Spalte für den Bildnamen hinzugefügt.

Gruß Jan

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Import von Schlüsselwörtern - Globale Namenszuweisung
« Reply #11 on: December 31, 2002, 09:23:00 AM »
I edited the script to work with version 1.7. Download the script and try it again.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline nwpw

  • Pre-Newbie
  • Posts: 6
    • View Profile
    • http://www.nwpw.com
Revision
« Reply #12 on: December 31, 2002, 05:55:28 PM »
Jan,

The script still refuses to insert the data into the index tables...  I'm currently trying to see if I can spot the reason in your modified script but, your coding is several levels above mine so...

Nick
 
Quote from: Jan
I edited the script to work with version 1.7. Download the script and try it again.

Jan

Offline nwpw

  • Pre-Newbie
  • Posts: 6
    • View Profile
    • http://www.nwpw.com
My Fix
« Reply #13 on: December 31, 2002, 07:17:34 PM »
Hi again,

I managed to get the import script to work for me by changing:

Code: [Select]
$search_words = array();

TO

Code: [Select]
$search_words = array($row['image_keywords'], $row['image_description'], $row['image_custom_fields']);

AND by removing (lines 74-78, I think):

Code: [Select]
foreach ($search_match_fields as $image_column => $match_column) {
if (isset($HTTP_POST_VARS[$image_column])) {
$search_words[$image_column] = stripslashes($row[$image_column]);
}
}


I'm sure it could have been fixed without removing those 4 lines but I don't have the time to figure that problem out...

Quote from: Jan
I edited the script to work with version 1.7. Download the script and try it again.

Jan

Offline Bodyworks

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • http://www.digitalfotos-online.de
Import von Description und Keywords funzt nicht
« Reply #14 on: April 15, 2003, 06:07:58 PM »
Hallo Jan,

ich habe versucht, gemäß dieses Threads Daten aus Extensis Portfolio nach 4images zu importieren. Leider ohne Erfolg.
Zuerst habe ich eine Kat (ID 40) angelegt, danach per FTP Bilder hochgeladen und dann mit Check neue Bilder importiert. Soweit alles o.k.

Mit Extensis Portfolio habe ich dann eine TXT-Datei in diesem Format erstellt:

Code: [Select]
crw_1828.jpg Fort Sagres AlgarveCarvoeiraPortugal
crw_1799.jpg Fort Sagres AlgarveCarvoeiraPortugal
crw_1800.jpg Fort Sagres AlgarveCarvoeiraPortugal
crw_1801.jpg Fort Sagres AlgarveCarvoeiraPortugal
crw_1806.jpg Fort Sagres AlgarveCarvoeiraPortugal
crw_1810.jpg Fort Sagres AlgarveCarvoeiraPortugal
crw_1814.jpg Fort Sagres AlgarveCarvoeiraPortugal
crw_1817.jpg Fort Sagres AlgarveCarvoeiraPortugal
crw_1818.jpg Fort Sagres AlgarveCarvoeiraPortugal
crw_1819.jpg Fort Sagres AlgarveCarvoeiraPortugal
crw_1821.jpg Fort Sagres AlgarveCarvoeiraPortugal
... usw


Beim Import erhalte ich dann für alle zu importierenden Bilder SQL-Fehlermeldungen wie folgt:

Code: [Select]
Update ID crw_1828.jpg Fort Sagres AlgarveCarvoeiraPortugal....
DB Error: Bad SQL Query: UPDATE 4images_images SET image_name = '', image_description = '', image_keywords = '' WHERE image_id = crw_1828.jpg Fort Sagres AlgarveCarvoeiraPortugal
You have an error in your SQL syntax near 'Fort Sagres AlgarveCarvoeiraPortugal' at line 3

DB Error: Bad SQL Query: SELECT image_id, image_name, image_description, image_keywords FROM 4images_images WHERE image_id = crw_1828.jpg Fort Sagres AlgarveCarvoeiraPortugal
You have an error in your SQL syntax near 'Fort Sagres AlgarveCarvoeiraPortugal' at line 3
Image not found.
Update ID crw_1799.jpg Fort Sagres AlgarveCarvoeiraPortugal....
DB Error: Bad SQL Query: UPDATE 4images_images SET image_name = '', image_description = '', image_keywords = '' WHERE image_id = crw_1799.jpg Fort Sagres AlgarveCarvoeiraPortugal
You have an error in your SQL syntax near 'Fort Sagres AlgarveCarvoeiraPortugal' at line 3

DB Error: Bad SQL Query: SELECT image_id, image_name, image_description, image_keywords FROM 4images_images WHERE image_id = crw_1799.jpg Fort Sagres AlgarveCarvoeiraPortugal
You have an error in your SQL syntax near 'Fort Sagres AlgarveCarvoeiraPortugal' at line 3
Image not found.
Update ID crw_1800.jpg Fort Sagres AlgarveCarvoeiraPortugal....
DB Error: Bad SQL Query: UPDATE 4images_images SET image_name = '', image_description = '', image_keywords = '' WHERE image_id = crw_1800.jpg Fort Sagres AlgarveCarvoeiraPortugal
You have an error in your SQL syntax near 'Fort Sagres AlgarveCarvoeiraPortugal' at line 3

.... usw

0 Einträge importiert


Ich habe dieses Script verwendet:

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File&#58; backup.php                                           *
 *        Copyright&#58; &#40;C&#41; 2002 Jan Sorgalla                                *
 *            Email&#58; jan@4homepages.de                                    *
 *              Web&#58; http&#58;//www.4homepages.de                             *
 *    Scriptversion&#58; 1.0                                                  *
 *                                                                        *
 *    Never released without support from&#58; Nicky &#40;http&#58;//www.nicky.net&#41;   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen &#40;Lizenz.txt&#41; für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    &#40;Licence.txt&#41; for further information.                              *
 *                                                                        *
 *************************************************************************/

$nozip 1;
define&#40;'IN_CP', 1&#41;;
define&#40;'ROOT_PATH', './../'&#41;;
require&#40;'admin_global.php'&#41;;
include&#40;ROOT_PATH.'includes/search_utils.php'&#41;;

if &#40;$action == ""&#41; &#123;
  
$action "importintro";
&
#125;

show_admin_header&#40;&#41;;

if &#40;$action == "startimport"&#41; &#123;
  
if &#40;$HTTP_POST_FILES['file'&#93;['tmp_name'&#93; != "none"&#41; &#123;
    
$cont file&#40;$HTTP_POST_FILES['file'&#93;['tmp_name'&#93;&#41;;
    
if&#40;!empty&#40;$cont&#41;&#41; &#123;
      
$data = array&#40;&#41;;
      
$count 0;
      while&
#40;list&#40;$key, $val&#41; = each&#40;$cont&#41;&#41; &#123;
        
$line explode&#40;"|", $val&#41;;
        
$line[0&#93; = trim&#40;$line[0&#93;&#41;;
        
$search_index_match "";
        if &
#40;preg_match&#40;"/\.[a-z&#93;&#123;2,4&#125;$/", $line[0&#93;&#41;&#41; &#123;
          
echo "Update ".$line[0&#93;."....";
          
flush&#40;&#41;;
          
@set_time_limit&#40;90&#41;;
          
$site_db->query&#40;"UPDATE ".IMAGES_TABLE." 
                           
SET image_name '".addslashes&#40;trim&#40;$line[1&#93;&#41;&#41;."'image_description '".addslashes&#40;trim&#40;$line[2&#93;&#41;&#41;."'image_keywords '".addslashes&#40;trim&#40;$line[3&#93;&#41;&#41;."' 
                           
WHERE image_media_file '".$line[0&#93;."'"&#41;;
          
$search_index_match = "image_media_file '".$line[0&#93;."'";
        &#125;
        else &#123;
          echo "
Update ID ".$line[0&#93;."....";
          flush&#40;&#41;;
          @set_time_limit&#40;90&#41;;
          
$site_db->query&#40;"UPDATE ".IMAGES_TABLE." 
                           
SET image_name '".addslashes&#40;trim&#40;$line[1&#93;&#41;&#41;."'image_description '".addslashes&#40;trim&#40;$line[2&#93;&#41;&#41;."'image_keywords '".addslashes&#40;trim&#40;$line[3&#93;&#41;&#41;."' 
                           
WHERE image_id ".$line[0&#93;&#41;;
          
$search_index_match = "image_id ".$line[0&#93;;
        &#125;
        
        if &#40;!empty&#40;
$search_index_match&#41;&#41; &#123;
          
$row = $site_db->query_firstrow&#40;"SELECT image_idimage_nameimage_descriptionimage_keywords 
                                           FROM 
".IMAGES_TABLE."
                                           
WHERE $search_index_match"&#41;;
          if &#40;
$row&#41; &#123;
            remove_searchwords&#40;
$row['image_id'&#93;&#41;;
            
            
$search_words = array&#40;&#41;;
            foreach &#40;
$search_match_fields as $image_column => $match_column&#41; &#123;
              if &#40;isset&#40;
$HTTP_POST_VARS[$image_column&#93;&#41;&#41; &#123;
                
$search_words[$image_column&#93; = stripslashes&#40;$row[$image_column&#93;&#41;;
              &#125;
            &#125;
            add_searchwords&#40;
$row['image_id'&#93;, $search_words&#41;;

            echo "
<b>".$lang['resizing_image_success'&#93;."</b><br>";
            
$count++;
          &#125;
          else &#123;
            echo "
<b>Image not found.</b><br>";
          &#125;
        &#125;
      &#125;
    &#125;
    echo "
<p><b>".$count."</bEinträge importiert";
  &#125;
  else &#123;
    
$action = "importintro";
  &#125;
&#125;

if &#40;
$action == "importintro"&#41; &#123;
?>

<form method="post" action="<?php echo $self_url ?>" enctype="multipart/form-data">
  Importfile:<br />
  <input type="file" name="file"><br /><br />
  <input type="submit" name="Abschicken" value="Start Import" class="button">
  <input type="hidden" name="action" value="startimport">
</form>
<?php
&#125;
show_admin_footer&#40;&#41;;
?>



Ich habe leider (noch) keinen Dunst von PHP und weiss nicht, warum es nicht funktioniert. Ich vermute mal, es liegt an der image_id, weil die nicht aus Extensis Portfolio an die TXT-Datei übergeben wird.

Jan, wenn Du das liest, gib mir bitte mal einen Tipp.

Beste Gruesse
Regards
Bodyworks