View Issue Details

IDProjectCategoryView StatusLast Update
0015956ScribusScripterpublic2019-11-28 17:08
Reporterale Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Product Version1.5.6.svn 
Target VersionFixed in Version 
Summary0015956: Letting the scripter access more / all EXIF fields of an image
DescriptionScribus does read the EXIF fields of images. But it only reads a few selected fields.

This is ok for the "more info" command, but a user is asking filling the caption of an image with the content of "other" EXIF fields.
TagsNo tags attached.
PatchNo

Activities

ale

2019-11-18 14:40

manager   ~0047101

Now, that this would be easy to add if Scribus would read all EXIF field.

Is there good reason why Scribus does not read the whole EXIF information?

ale

2019-11-18 14:46

manager   ~0047102

for my future self:

- exif.cpp contains the code that reads the EXIF information. with an (out-commented) list of all possible EXIF fields
- in order to find where the data is stored / read, one can start from "context menu > image > more info"
- i attach the diff that adds the getimageexiffield() scripter command
- i also attach an image that can be used to check the extended fields

scripter-getexif.diff (4,353 bytes)
diff --git a/scribus/plugins/scriptplugin/cmdgetprop.cpp b/scribus/plugins/scriptplugin/cmdgetprop.cpp
index a2040f196..aa7483c92 100644
--- a/scribus/plugins/scriptplugin/cmdgetprop.cpp
+++ b/scribus/plugins/scriptplugin/cmdgetprop.cpp
@@ -255,6 +255,28 @@ PyObject *scribus_getimgscale(PyObject* /* self */, PyObject* args)
 	return Py_BuildValue("(ff)", item->imageXScale() / 72.0 * item->pixm.imgInfo.xres, item->imageYScale() / 72.0 * item->pixm.imgInfo.yres);
 }
 
+PyObject *scribus_getimageexiffield(PyObject* /* self */, PyObject* args)
+{
+	char *Name = const_cast<char*>("");
+	char *Field;
+	if (!PyArg_ParseTuple(args, "es|es", &Field, "utf-8", &Name))
+		return nullptr;
+	if (!checkHaveDocument())
+		return nullptr;
+	PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+	if (item == nullptr)
+		return nullptr;
+	if (item->itemType() != PageItem::ImageFrame)
+		return nullptr;
+
+	// ImageInfoDialog *dia = new ImageInfoDialog(this, &pageItem->pixm.imgInfo);
+	// timeInfo = new QLabel( info->exifInfo.dateTime, GenGroup);
+	ExifValues exif = item->pixm.imgInfo.exifInfo;
+
+	// return PyUnicode_FromString(item->Pfile.toUtf8());
+	return PyUnicode_FromString("abcd");
+}
+
 PyObject *scribus_getimagefile(PyObject* /* self */, PyObject* args)
 {
 	char *Name = const_cast<char*>("");
@@ -460,6 +482,7 @@ void cmdgetpropdocwarnings()
 	  << scribus_getlineshade__doc__ << scribus_getlinejoin__doc__ 
 	  << scribus_getlinecap__doc__ << scribus_getlinestyle__doc__ 
 	  << scribus_getfillshade__doc__ << scribus_getcornerrad__doc__ 
+	  << scribus_getimageexiffield__doc__ 
 	  << scribus_getimgscale__doc__ << scribus_getimagefile__doc__ 
 	  << scribus_getposi__doc__ << scribus_getsize__doc__ 
 	  << scribus_getrotation__doc__ <<  scribus_getallobj__doc__
diff --git a/scribus/plugins/scriptplugin/cmdgetprop.h b/scribus/plugins/scriptplugin/cmdgetprop.h
index e2260a3d0..39d8f52e9 100644
--- a/scribus/plugins/scriptplugin/cmdgetprop.h
+++ b/scribus/plugins/scriptplugin/cmdgetprop.h
@@ -176,6 +176,16 @@ If \"name\" is not given the currently selected item is used.\n\
 "));
 PyObject *scribus_getimagecolorspace(PyObject * /*self*/, PyObject* args);
 
+/*! docstring */
+PyDoc_STRVAR(scribus_getimageexiffield__doc__,
+QT_TR_NOOP("getImageExifField(fiel, [\"name\"]) -> string\n\
+\n\
+Returns the exif field for the image in the image frame. If \"name\" is not\n\
+given the currently selected item is used.\n\
+"));
+/*! Returns image name of the object */
+PyObject *scribus_getimageexiffield(PyObject * /*self*/, PyObject* args);
+
 /*! docstring */
 PyDoc_STRVAR(scribus_getimagefile__doc__,
 QT_TR_NOOP("getImageFile([\"name\"]) -> string\n\
diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp
index d76ccba7b..5a798934d 100644
--- a/scribus/plugins/scriptplugin/scriptplugin.cpp
+++ b/scribus/plugins/scriptplugin/scriptplugin.cpp
@@ -363,6 +363,7 @@ PyMethodDef scribus_methods[] = {
 	{const_cast<char*>("getHGuides"), (PyCFunction)scribus_getHguides, METH_NOARGS, tr(scribus_getHguides__doc__)},
 	{const_cast<char*>("getImageColorSpace"), scribus_getimagecolorspace, METH_VARARGS, tr(scribus_getimagecolorspace__doc__) },
 	{const_cast<char*>("getImageFile"), scribus_getimagefile, METH_VARARGS, tr(scribus_getimagefile__doc__)},
+	{const_cast<char*>("getImageExifField"), scribus_getimageexiffield, METH_VARARGS, tr(scribus_getimageexiffield__doc__)},
 	{const_cast<char*>("getImageOffset"), scribus_getimgoffset, METH_VARARGS, tr(scribus_getimgoffset__doc__)},
 	{const_cast<char*>("getImageScale"), scribus_getimgscale, METH_VARARGS, tr(scribus_getimgscale__doc__)},
 	{const_cast<char*>("getLayers"), (PyCFunction)scribus_getlayers, METH_NOARGS, tr(scribus_getlayers__doc__)},
@@ -980,5 +981,5 @@ PV */
 void scriptplugindocwarnings()
 {
 	QStringList s;
-	s <<printer__doc__<<pdffile__doc__<<imgexp__doc__<<imgexp_dpi__doc__<<imgexp_scale__doc__ <<imgexp_quality__doc__<<imgexp_filename__doc__<<imgexp_type__doc__<<imgexp_alltypes__doc__ << imgexp_save__doc__ << imgexp_saveas__doc__;
+	s <<printer__doc__<<pdffile__doc__<<imgexp__doc__<<imgexp_dpi__doc__<<imgexp_scale__doc__ << imgexp_transparentBkgnd__doc__ <<imgexp_quality__doc__<<imgexp_filename__doc__<<imgexp_type__doc__<<imgexp_alltypes__doc__ << imgexp_save__doc__ << imgexp_saveas__doc__;
 }
scripter-getexif.diff (4,353 bytes)
hiker-playmobil.jpg (299,038 bytes)
hiker-playmobil.jpg (299,038 bytes)

cbradney

2019-11-25 21:15

administrator   ~0047137

Patch applied in r23378

jghali

2019-11-26 01:13

administrator   ~0047139

@cbradney, have you noticed that the new scripter function currently only returns dummy data?

ale

2019-11-26 13:07

manager   ~0047142

yep, the patch was just for me so that i did not lose the previous work...

i shortly talked with jean about this and it's not clear why only part of the info is read... probably because it's that part that scribus uses.

adding a "real" libexif would add a bigger dependency (at least for windows and macos), so i can have a look at exif.cpp and see if i can use it to return the other fields too...

ale

2019-11-28 13:59

manager   ~0047158

Last edited: 2019-11-28 17:08

View 2 revisions

i will propose a "new" ExifData class.

for the review, here are the main changes:

- rename "ConvertAnyFormat" to "anyAsDouble
- fixed most spacing around the parenthesis
- use a QMap<QVariant> instead of the long list of specific fields
- introduce a getField(QString name) for the scripter (it can also be used by imagedataloaders/scimgdataloader_jpeg.cpp (so that we can remove the many specific functions)
- use floats instead of doubles

to be checked:

- is a QMap<QVariant> fast enough?

tbc

Issue History

Date Modified Username Field Change
2019-11-18 14:39 ale New Issue
2019-11-18 14:40 ale Note Added: 0047101
2019-11-18 14:46 ale File Added: scripter-getexif.diff
2019-11-18 14:46 ale File Added: hiker-playmobil.jpg
2019-11-18 14:46 ale Note Added: 0047102
2019-11-25 21:15 cbradney Note Added: 0047137
2019-11-26 01:13 jghali Note Added: 0047139
2019-11-26 13:07 ale Note Added: 0047142
2019-11-28 13:59 ale Note Added: 0047158
2019-11-28 17:08 ale Note Edited: 0047158 View Revisions