diff options
Diffstat (limited to 'tdefile-plugins/tiff')
-rw-r--r-- | tdefile-plugins/tiff/CMakeLists.txt | 37 | ||||
-rw-r--r-- | tdefile-plugins/tiff/ConfigureChecks.cmake | 21 | ||||
-rw-r--r-- | tdefile-plugins/tiff/Makefile.am | 21 | ||||
-rw-r--r-- | tdefile-plugins/tiff/configure.in.in | 3 | ||||
-rw-r--r-- | tdefile-plugins/tiff/tdefile_tiff.cpp | 299 | ||||
-rw-r--r-- | tdefile-plugins/tiff/tdefile_tiff.desktop | 67 | ||||
-rw-r--r-- | tdefile-plugins/tiff/tdefile_tiff.h | 43 |
7 files changed, 491 insertions, 0 deletions
diff --git a/tdefile-plugins/tiff/CMakeLists.txt b/tdefile-plugins/tiff/CMakeLists.txt new file mode 100644 index 00000000..d3ec9b90 --- /dev/null +++ b/tdefile-plugins/tiff/CMakeLists.txt @@ -0,0 +1,37 @@ +################################################# +# +# (C) 2010-2011 Calvin Morrison +# mutantturkey@gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include( ConfigureChecks.cmake ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +#### other data ################################# + +install( FILES tdefile_tiff.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) + + +#### tdefile_tiff (module) ######################## + +tde_add_kpart( tdefile_tiff AUTOMOC + SOURCES tdefile_tiff.cpp + LINK tdeio-shared ${TIFF_LIBRARY} + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdefile-plugins/tiff/ConfigureChecks.cmake b/tdefile-plugins/tiff/ConfigureChecks.cmake new file mode 100644 index 00000000..c7efb9b7 --- /dev/null +++ b/tdefile-plugins/tiff/ConfigureChecks.cmake @@ -0,0 +1,21 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +# libtiff +check_include_file( tiff.h HAVE_TIFF_H ) +if( HAVE_TIFF_H ) + check_library_exists( tiff TIFFOpen "" HAVE_TIFF ) +endif( ) +if( HAVE_TIFF_H AND HAVE_TIFF ) + set( TIFF_LIBRARY tiff ) +else( ) + tde_message_fatal( "libtiff is required, but was not found on your system" ) +endif( ) diff --git a/tdefile-plugins/tiff/Makefile.am b/tdefile-plugins/tiff/Makefile.am new file mode 100644 index 00000000..9807a66c --- /dev/null +++ b/tdefile-plugins/tiff/Makefile.am @@ -0,0 +1,21 @@ +## Makefile.am for Tiff file meta info plugin + +# set the include path for X, qt and KDE +INCLUDES = $(all_includes) + +noinst_HEADERS = tdefile_tiff.h + +kde_module_LTLIBRARIES = tdefile_tiff.la + +tdefile_tiff_la_SOURCES = tdefile_tiff.cpp +tdefile_tiff_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +tdefile_tiff_la_LIBADD = $(LIB_KIO) $(LIBTIFF) + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: + $(XGETTEXT) *.cpp -o $(podir)/tdefile_tiff.pot + +services_DATA = tdefile_tiff.desktop +servicesdir = $(kde_servicesdir) diff --git a/tdefile-plugins/tiff/configure.in.in b/tdefile-plugins/tiff/configure.in.in new file mode 100644 index 00000000..e1a9730a --- /dev/null +++ b/tdefile-plugins/tiff/configure.in.in @@ -0,0 +1,3 @@ +# Compile the tiff meta info plugin only if libtiff was detected +AC_FIND_TIFF +AM_CONDITIONAL(include_TIFF, test -n "$LIBTIFF") diff --git a/tdefile-plugins/tiff/tdefile_tiff.cpp b/tdefile-plugins/tiff/tdefile_tiff.cpp new file mode 100644 index 00000000..dfd813a5 --- /dev/null +++ b/tdefile-plugins/tiff/tdefile_tiff.cpp @@ -0,0 +1,299 @@ +/* This file is part of the KDE project + * Copyright (C) 2002 Nadeem Hasan <nhasan@kde.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "tdefile_tiff.h" + +#include <kgenericfactory.h> +#include <kdebug.h> + +#include <tqstringlist.h> +#include <tqfile.h> +#include <tqdatetime.h> +#include <tqregexp.h> + +#include <tiff.h> +#include <tiffio.h> + +typedef KGenericFactory<KTiffPlugin> TiffFactory; + +K_EXPORT_COMPONENT_FACTORY(tdefile_tiff, TiffFactory("tdefile_tiff")) + +KTiffPlugin::KTiffPlugin(TQObject *parent, const char *name, + const TQStringList &args) : KFilePlugin(parent, name, args) +{ + kdDebug(7034) << "TIFF file meta info plugin" << endl; + KFileMimeTypeInfo* info = addMimeTypeInfo( "image/tiff" ); + + KFileMimeTypeInfo::GroupInfo* group = + addGroupInfo(info, "General", i18n("General")); + + KFileMimeTypeInfo::ItemInfo* item; + item = addItemInfo(group, "Description", i18n("Description"), + TQVariant::String); + setHint(item, KFileMimeTypeInfo::Description); + item = addItemInfo(group, "Copyright", i18n("Copyright"), + TQVariant::String); + item = addItemInfo(group, "ColorMode", i18n("Color Mode"), + TQVariant::String); + item = addItemInfo(group, "Dimensions", i18n("Dimensions"), + TQVariant::Size); + setHint(item, KFileMimeTypeInfo::Size); + setUnit(item, KFileMimeTypeInfo::Pixels); + item = addItemInfo(group, "Resolution", i18n("Resolution"), + TQVariant::Size); + setUnit(item, KFileMimeTypeInfo::DotsPerInch); + item = addItemInfo(group, "BitDepth", i18n("Bit Depth"), + TQVariant::Int); + setUnit(item, KFileMimeTypeInfo::BitsPerPixel); + item = addItemInfo(group, "Compression", i18n("Compression"), + TQVariant::String); + item = addItemInfo(group, "Software", i18n("Software"), + TQVariant::String); + item = addItemInfo(group, "DateTime", i18n("Date/Time"), + TQVariant::DateTime); + item = addItemInfo(group, "Artist", i18n("Artist"), + TQVariant::String); + setHint(item, KFileMimeTypeInfo::Author); + item = addItemInfo(group, "FaxPages", i18n("Fax Pages"), + TQVariant::Int); + + group = addGroupInfo(info, "Scanner", i18n("Scanner")); + + item = addItemInfo(group, "Make", i18n("Make"), TQVariant::String); + item = addItemInfo(group, "Model", i18n("Model"), TQVariant::String); + + m_colorMode.setAutoDelete(true); + m_imageCompression.setAutoDelete(true); + + m_colorMode.insert(PHOTOMETRIC_MINISWHITE, + new TQString(I18N_NOOP("Monochrome"))); + m_colorMode.insert(PHOTOMETRIC_MINISBLACK, + new TQString(I18N_NOOP("Monochrome"))); + m_colorMode.insert(PHOTOMETRIC_RGB, + new TQString(I18N_NOOP("RGB"))); + m_colorMode.insert(PHOTOMETRIC_PALETTE, + new TQString(I18N_NOOP("Palette color"))); + m_colorMode.insert(PHOTOMETRIC_MASK, + new TQString(I18N_NOOP("Transparency mask"))); + m_colorMode.insert(PHOTOMETRIC_SEPARATED, + new TQString(I18N_NOOP("Color separations"))); + m_colorMode.insert(PHOTOMETRIC_YCBCR, + new TQString(I18N_NOOP("YCbCr"))); + m_colorMode.insert(PHOTOMETRIC_CIELAB, + new TQString(I18N_NOOP("CIE Lab"))); +#ifdef PHOTOMETRIC_ITULAB + m_colorMode.insert(PHOTOMETRIC_ITULAB, + new TQString(I18N_NOOP("ITU Lab"))); +#endif + m_colorMode.insert(PHOTOMETRIC_LOGL, + new TQString(I18N_NOOP("LOGL"))); + m_colorMode.insert(PHOTOMETRIC_LOGLUV, + new TQString(I18N_NOOP("LOGLUV"))); + + m_imageCompression.insert(COMPRESSION_NONE, + new TQString(I18N_NOOP("None"))); + m_imageCompression.insert(COMPRESSION_CCITTRLE, + new TQString(I18N_NOOP("RLE"))); + m_imageCompression.insert(COMPRESSION_CCITTFAX3, + new TQString(I18N_NOOP("G3 Fax"))); + m_imageCompression.insert(COMPRESSION_CCITTFAX4, + new TQString(I18N_NOOP("G4 Fax"))); + m_imageCompression.insert(COMPRESSION_LZW, + new TQString(I18N_NOOP("LZW"))); + m_imageCompression.insert(COMPRESSION_OJPEG, + new TQString(I18N_NOOP("JPEG"))); + m_imageCompression.insert(COMPRESSION_JPEG, + new TQString(I18N_NOOP("JPEG DCT"))); +#ifdef COMPRESSION_ADOBE_DEFLATE + m_imageCompression.insert(COMPRESSION_ADOBE_DEFLATE, + new TQString(I18N_NOOP("Adobe Deflate"))); +#endif + m_imageCompression.insert(COMPRESSION_NEXT, + new TQString(I18N_NOOP("NeXT 2-bit RLE"))); + m_imageCompression.insert(COMPRESSION_CCITTRLEW, + new TQString(I18N_NOOP("RLE Word"))); + m_imageCompression.insert(COMPRESSION_PACKBITS, + new TQString(I18N_NOOP("Packbits"))); + m_imageCompression.insert(COMPRESSION_THUNDERSCAN, + new TQString(I18N_NOOP("Thunderscan RLE"))); + m_imageCompression.insert(COMPRESSION_IT8CTPAD, + new TQString(I18N_NOOP("IT8 CT w/padding"))); + m_imageCompression.insert(COMPRESSION_IT8LW, + new TQString(I18N_NOOP("IT8 linework RLE"))); + m_imageCompression.insert(COMPRESSION_IT8MP, + new TQString(I18N_NOOP("IT8 monochrome"))); + m_imageCompression.insert(COMPRESSION_IT8BL, + new TQString(I18N_NOOP("IT8 binary lineart"))); + m_imageCompression.insert(COMPRESSION_PIXARFILM, + new TQString(I18N_NOOP("Pixar 10-bit LZW"))); + m_imageCompression.insert(COMPRESSION_PIXARLOG, + new TQString(I18N_NOOP("Pixar 11-bit ZIP"))); + m_imageCompression.insert(COMPRESSION_DEFLATE, + new TQString(I18N_NOOP("Pixar deflate"))); + m_imageCompression.insert(COMPRESSION_DCS, + new TQString(I18N_NOOP("Kodak DCS"))); + m_imageCompression.insert(COMPRESSION_JBIG, + new TQString(I18N_NOOP("ISO JBIG"))); + m_imageCompression.insert(COMPRESSION_SGILOG, + new TQString(I18N_NOOP("SGI log luminance RLE"))); + m_imageCompression.insert(COMPRESSION_SGILOG24, + new TQString(I18N_NOOP("SGI log 24-bit packed"))); +} + +TQDateTime KTiffPlugin::tiffDate(const TQString& s) const +{ + TQDateTime dt; + TQRegExp rxDate("^([0-9]{4}):([0-9]{2}):([0-9]{2})\\s" + "([0-9]{2}):([0-9]{2}):([0-9]{2})$"); + + if (rxDate.search(s) != -1) + { + int year = rxDate.cap(1).toInt(); + int month = rxDate.cap(2).toInt(); + int day = rxDate.cap(3).toInt(); + int hour = rxDate.cap(4).toInt(); + int min = rxDate.cap(5).toInt(); + int sec = rxDate.cap(6).toInt(); + + TQDate d = TQDate(year, month, day); + TQTime t = TQTime(hour, min, sec); + + if (d.isValid() && t.isValid()) + { + dt.setDate(d); + dt.setTime(t); + } + } + + return dt; +} + +bool KTiffPlugin::readInfo(KFileMetaInfo& info, uint) +{ + TIFF *tiff = TIFFOpen(TQFile::encodeName(info.path()), "r"); + if (!tiff) + return false; + + uint32 imageLength=0, imageWidth=0; + uint16 bitsPerSample=0, imageCompression=0, colorMode=0, samplesPerPixel=0, + imageAlpha=0, imageResUnit=0, dummy=0, faxPages=0; + float imageXResolution=0, imageYResolution=0; + char *description=0, *copyright=0, *software=0, *datetime=0, *artist=0, + *scannerMake=0, *scannerModel=0; + + TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &imageLength); + TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &imageWidth); + TIFFGetFieldDefaulted(tiff, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); + TIFFGetFieldDefaulted(tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel); + TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &colorMode); + TIFFGetFieldDefaulted(tiff, TIFFTAG_COMPRESSION, &imageCompression); + TIFFGetField(tiff, TIFFTAG_MATTEING, &imageAlpha); + TIFFGetField(tiff, TIFFTAG_XRESOLUTION, &imageXResolution); + TIFFGetField(tiff, TIFFTAG_YRESOLUTION, &imageYResolution); + TIFFGetFieldDefaulted(tiff, TIFFTAG_RESOLUTIONUNIT, &imageResUnit); + TIFFGetField(tiff, TIFFTAG_IMAGEDESCRIPTION, &description); + TIFFGetField(tiff, TIFFTAG_SOFTWARE, &software); + TIFFGetField(tiff, TIFFTAG_COPYRIGHT, ©right); + TIFFGetField(tiff, TIFFTAG_DATETIME, &datetime); + TIFFGetField(tiff, TIFFTAG_ARTIST, &artist); + TIFFGetField(tiff, TIFFTAG_PAGENUMBER, &dummy, &faxPages); + TIFFGetField(tiff, TIFFTAG_MAKE, &scannerMake); + TIFFGetField(tiff, TIFFTAG_MODEL, &scannerModel); + + kdDebug(7034) << "Description: " << description << endl; + kdDebug(7034) << "Width: " << imageWidth << endl; + kdDebug(7034) << "Height: " << imageLength << endl; + kdDebug(7034) << "BitDepth: " << bitsPerSample << endl; + kdDebug(7034) << "ColorMode: " << colorMode << endl; + kdDebug(7034) << "Compression: " << imageCompression << endl; + kdDebug(7034) << "SamplesPerPixel: " << samplesPerPixel << endl; + kdDebug(7034) << "ImageAlpha: " << imageAlpha << endl; + kdDebug(7034) << "XResolution: " << imageXResolution << endl; + kdDebug(7034) << "YResolution: " << imageYResolution << endl; + kdDebug(7034) << "ResolutionUnit: " << imageResUnit << endl; + kdDebug(7034) << "FaxPages: " << faxPages << endl; + kdDebug(7034) << "DateTime: " << datetime << endl; + kdDebug(7034) << "Copyright: " << copyright << endl; + kdDebug(7034) << "Software: " << software << endl; + kdDebug(7034) << "Artist: " << artist << endl; + kdDebug(7034) << "Make: " << scannerMake << endl; + kdDebug(7034) << "Model: " << scannerModel << endl; + + if (imageResUnit == RESUNIT_CENTIMETER) + { + imageXResolution *= 2.54; + imageYResolution *= 2.54; + } + else if (imageResUnit == RESUNIT_NONE) + { + imageXResolution = 0; + imageYResolution = 0; + } + + int imageBpp = bitsPerSample*samplesPerPixel; + if (imageAlpha && colorMode==PHOTOMETRIC_RGB) + m_colorMode.replace(PHOTOMETRIC_RGB, new TQString(I18N_NOOP("RGBA"))); + + KFileMetaInfoGroup group = appendGroup(info, "General"); + if (description) + appendItem(group, "Description", TQString(description)); + appendItem(group, "Dimensions", TQSize(imageWidth, imageLength)); + appendItem(group, "BitDepth", imageBpp); + if (imageXResolution>0 && imageYResolution>0) + appendItem(group, "Resolution", TQSize( + static_cast<int>(imageXResolution), + static_cast<int>(imageYResolution))); + if (m_colorMode[colorMode]) + appendItem(group, "ColorMode", *m_colorMode[colorMode]); + if (m_imageCompression[imageCompression]) + appendItem(group, "Compression", *m_imageCompression[imageCompression]); + if (datetime) + { + TQDateTime dt = tiffDate(TQString(datetime)); + if (dt.isValid()) + appendItem(group, "DateTime", dt); + } + if (copyright) + appendItem(group, "Copyright", TQString(copyright)); + if (software) + appendItem(group, "Software", TQString(software)); + if (artist) + appendItem(group, "Artist", TQString(artist)); + + if (faxPages>0 && (imageCompression==COMPRESSION_CCITTFAX3 || + imageCompression==COMPRESSION_CCITTFAX4)) + { + appendItem(group, "FaxPages", faxPages); + } + + if (scannerMake || scannerModel) + { + group = appendGroup(info, "Scanner"); + if (scannerMake) + appendItem(group, "Make", TQString(scannerMake)); + if (scannerModel) + appendItem(group, "Model", TQString(scannerModel)); + } + + TIFFClose(tiff); + + return true; +} + +#include "tdefile_tiff.moc" diff --git a/tdefile-plugins/tiff/tdefile_tiff.desktop b/tdefile-plugins/tiff/tdefile_tiff.desktop new file mode 100644 index 00000000..1309e3a3 --- /dev/null +++ b/tdefile-plugins/tiff/tdefile_tiff.desktop @@ -0,0 +1,67 @@ +[Desktop Entry] +Type=Service +Name=TIFF File Meta Info +Name[af]=Tiff Lêer Meta Inligting +Name[ar]=معلومات ملف TIFF +Name[br]=Meta-titouroù ar restr TIFF +Name[ca]=Metainformació de fitxer TIFF +Name[cs]=Metainformace obrázku typu TIFF +Name[cy]=Meta-wybodaeth Ffeil TIFF +Name[da]=TIFF Fil-meta-info +Name[de]=TIFF-Metainformation +Name[el]=Μετα-πληροφορίες αρχείου TIFF +Name[eo]=TIFF-informo +Name[es]=Info meta de archivos TIFF +Name[et]=TIFF faili metainfo +Name[eu]=TIFF fitxategi meta info +Name[fa]=فرااطلاعات پروندۀ TIFF +Name[fi]=TIFF-metatiedot +Name[fr]=Méta Informations sur les fichiers TIFF +Name[gl]=Inf. metaficheiro TIFF +Name[he]=מידע TIFF +Name[hi]=TIFF फ़ाइल मेटा जानकारी +Name[hr]=TIFF meta informacije +Name[hu]=TIFF-metajellemzők +Name[is]=TIFF File Meta upplýsingar +Name[it]=Informazioni TIFF +Name[ja]=TIFF ファイルメタ情報 +Name[kk]=TIFF файлдың мета деректері +Name[km]=ព័ត៌មានមេតារបស់ឯកសារ TIFF +Name[lt]=TIFF bylos meta informacija +Name[ms]=TIFF Maklumat Meta Fail TIFF +Name[nb]=TIFF-filmetainfo +Name[nds]=TIFF-Metainfo +Name[ne]=TIFF फाइल मेटा सूचना +Name[nl]=TIFF File Meta-info +Name[nn]=TIFF-filmetainfo +Name[nso]=Tshedimoso ya Meta wa Faele ya TIFF +Name[pl]=Informacja o pliku TIFF +Name[pt]=Meta-Informação do Ficheiro TIFF +Name[pt_BR]=Informação sobre Meta Arquivo TIFF +Name[ro]=Metainformaţii TIFF +Name[ru]=Информация о метафайле TIFF +Name[se]=TIFF-filla metadieđut +Name[sk]=Meta-info o súbore TIFF +Name[sl]=Meta podatki o TIFF +Name[sr]=Мета информације TIFF фајла +Name[sr@Latn]=Meta informacije TIFF fajla +Name[sv]=Metainformation om TIFF-fil +Name[ta]=TIFF மீக்கோப்பு தகவல் +Name[tg]=Иттилоот оиди метафайли TIFF +Name[th]=ข้อมูลเมตาแฟ้ม TIFF +Name[tr]=TIFF Dosya Bilgisi +Name[uk]=Метаінформація про файл TIFF +Name[uz]=TIFF-faylining meta-maʼlumoti +Name[uz@cyrillic]=TIFF-файлининг мета-маълумоти +Name[ven]=Mafhungo a Meta faela ya TIFF +Name[wa]=Informåcion sol imådje TIFF +Name[xh]=Ulwazi lwe TIFF Ifayile Esembindini +Name[zh_CN]=TIFF 文件元信息 +Name[zh_HK]=TIFF 檔案 Meta 資訊 +Name[zh_TW]=TIFF 檔案 Meta 資訊 +Name[zu]=Ulwazi Lwefayela yemeta ye-TIFF +ServiceTypes=KFilePlugin +X-TDE-Library=tdefile_tiff +MimeType=image/tiff +PreferredGroups=General,Scanner +PreferredItems=Description,Copyright,Type,Dimensions,Resolution,BitDepth,Compression,Software,DateTime,Artist,FaxPages,Make,Model diff --git a/tdefile-plugins/tiff/tdefile_tiff.h b/tdefile-plugins/tiff/tdefile_tiff.h new file mode 100644 index 00000000..e34eef25 --- /dev/null +++ b/tdefile-plugins/tiff/tdefile_tiff.h @@ -0,0 +1,43 @@ +/* This file is part of the KDE project + * Copyright (C) 2002 Nadeem Hasan <nhasan@kde.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef __KFILE_TIFF_H_ +#define __KFILE_TIFF_H_ + +#include <tdefilemetainfo.h> + +#include <tqintdict.h> + +class KTiffPlugin: public KFilePlugin +{ + Q_OBJECT + + +public: + KTiffPlugin(TQObject *parent, const char *name, const TQStringList& args); + virtual bool readInfo(KFileMetaInfo& info, uint what); + +private: + TQDateTime tiffDate(const TQString&) const; + + TQIntDict<TQString> m_colorMode; + TQIntDict<TQString> m_imageCompression; +}; + +#endif |