Skip to content

Inserting image failed due to inappropriate exif data : 1406 Data too long for column #83

@florianj1

Description

@florianj1

I used lycheesync to import a large amount of photos into my server, however for some of them the import failed with an error:

1406 Data too long for row

When I took a closer look I found that focal of the exif information is to large for the mysql database. In my case focal is 16.799999237060547 mm, which is longer than 20 Byte!

mysql> describe lychee_photos;
+-------------+---------------------+------+-----+---------+-------+
| Field       | Type                | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| id          | bigint(14) unsigned | NO   | PRI | NULL    |       |
| title       | varchar(100)        | NO   |     |         |       |
| description | varchar(1000)       | YES  |     |         |       |
| url         | varchar(100)        | NO   |     | NULL    |       |
| tags        | varchar(1000)       | NO   |     |         |       |
| public      | tinyint(1)          | NO   |     | NULL    |       |
| type        | varchar(10)         | NO   |     | NULL    |       |
| width       | int(11)             | NO   |     | NULL    |       |
| height      | int(11)             | NO   |     | NULL    |       |
| size        | varchar(20)         | NO   |     | NULL    |       |
| iso         | varchar(15)         | NO   |     | NULL    |       |
| aperture    | varchar(20)         | NO   |     | NULL    |       |
| make        | varchar(50)         | NO   |     | NULL    |       |
| model       | varchar(50)         | NO   |     | NULL    |       |
| shutter     | varchar(30)         | NO   |     | NULL    |       |
| focal       | varchar(20)         | NO   |     | NULL    |       |
| takestamp   | int(11)             | YES  |     | NULL    |       |
| star        | tinyint(1)          | NO   | MUL | NULL    |       |
| thumbUrl    | char(37)            | NO   |     | NULL    |       |
| album       | bigint(14) unsigned | NO   | MUL | NULL    |       |
| checksum    | char(40)            | YES  |     | NULL    |       |
| medium      | tinyint(1)          | NO   |     | 0       |       |
+-------------+---------------------+------+-----+---------+-------+

I changed the code as follows and everything is working for now:


diff --git a/lycheesync/lycheedao.py b/lycheesync/lycheedao.py
index 5e837de..7a744b5 100644
--- a/lycheesync/lycheedao.py
+++ b/lycheesync/lycheedao.py
@@ -487,6 +487,12 @@ class LycheeDAO:
         except Exception as e:
             stamp = datetime.datetime.now().strftime('%s')

+        if len(photo.exif.focal) > 20:
+            if photo.exif.focal[-2:] == "mm":
+                photo.exif.focal = photo.exif.focal[0:17] + photo.exif.focal[-3:0]
+            else:
+                photo.exif.focal = photo.exif.focal[0:20]
+
         query = ("insert into lychee_photos " +
                  "(id, url, public, type, width, height, " +
                  "size, star, " +

Is it ok to perform the checks at this location or would you recommed something else?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions