Commit Graph

57 Commits

Author SHA1 Message Date
Jehan df074bfe09 plug-ins: label and documentation of plug-ins localized plug-in side.
This is the consequence of previous commit. Plug-ins' label and
documentation are now localized before sending these data to GIMP core.
In other words, we replace N_() macros with basic gettext calls.
2022-07-05 12:23:51 +02:00
Jehan 18c37f7084 plug-ins, libgimp: override set_i18n() for all our core plug-ins.
Hence avoiding the stderr messages. These are going to be localized with
centrally installed catalogs "gimp*-std-plugins", "gimp*-script-fu" and
"gimp*-python".

We now handle core plug-in localizations differently and in particular,
with kind of a reverse logic:

- We don't consider "gimp*-std-plugins" to be the default catalog
  anymore. It made sense in the old world where we would consider the
  core plug-ins to be the most important and numerous ones. But we want
  to push a world where people are even more encouraged to develop their
  own plug-ins. These won't use the standard catalog anymore (because
  there are nearly no reasons that the strings are the same, it's only a
  confusing logic). So let's explicitly set the standard catalogs with
  DEFINE_STD_SET_I18N macro (which maps to a different catalog for
  script-fu plug-ins).
- Doing something similar for Python plug-ins which have again their own
  catalog.
- Getting rid of the INIT_I18N macro since now all the locale domain
  binding is done automatically by libgimp when using the set_i18n()
  method infrastructure.
2022-06-05 01:57:02 +02:00
Jehan f200594d1c plug-ins: support CMYK import/export for JPEG.
We already had import support through littleCMS. We now use fully
babl/GEGL which makes our code more straightforward and identical,
whichever the input format.

The export support is totally new. It comes with a checkbox to propose
selecting CMYK export and a label displaying the CMYK profile which will
be used.

Now this whole implementation has a few drawbacks so far, but it will be
a good first sample for future CMYK-related improvements to come:

* The export profile I am using is what we call the "simulation
  profile" from the GimpColorConfig. This corresponds to the default
  "Soft-proofing" profile as set in Preferences. In particular, this is
  not the actual soft-proofing profile for this image which might have
  been changed through the View menu because this information is
  currently and unfortunately unavailable to plug-ins. It is not the
  "Preferred CMYK Profile" either, as set in Preferences.
  TODOS:
  - We really need to straighten the soft-proof profile core concept by
    storing it in the image and making it visible to plug-in.
  - Another interesting improvement could be to create a
    GimpColorProfile procedure argument which would be mapped to a color
    profile chooser widget, allowing people to choose profiles in
    plug-ins. For an export plug-in in particular, it could allow to
    select a profile different from the soft-proof one at export time.
* When we export, if no profile is choosen, babl will use a naive
  profile. It would be nice to store this naive profile into the JPEG if
  the "Save color profile" option is checked (same as we store a generic
  sRGB profile when no RGB profile is set).
* When we import, we just import the image as sRGB. Since CMYK gamuts
  are not necessarily within sRGB (some part of the spectrum is usually
  well within, but other well outside), other than the basic conversion
  accuracy issue, we may lose colors. It would be much nicer to be able
  to select an output RGB profile. Optionally if we could create a RGB
  color space which is made to contain the whole input CMYK profile
  color space, without explicit choice step, it would be nice too.
* I am using babl's "cmyk" format, not the expected "CMYK" format.
  "cmyk" is meant to be an inverted CMYK where 0.0 is full ink coverage
  and 1.0 none. Nevertheless when loading the resulting JPEG in other
  software (editors or viewers alike), the normal CMYK would always
  display inverted colors and the inverted cmyk would look fine.
  Finally I found a docs from libjpeg-turbo library, explaining that
  Photoshop was wrongly inverting CMYK color data while it should not.
  This text dates back from 1994, looking at the commit date which
  introduced this paragraph. In the 28 years since then, could this
  color inversion have become the de-facto standard for JPEG because one
  of the main editor would just output all its JPEG files this way?
  See: dfc63d42ee/libjpeg.txt (L1425-L1438)
2022-04-17 23:14:20 +02:00
Jehan 4f1007edbc Issue #6695: Wrong tab after JPG export because of "Show preview"…
… feature.
Using the new gimp_display_present() function in file-jpeg to make sure
the original display is back to the top.
2021-04-30 03:51:21 +02:00
Jehan aba721ae68 Issue #6280: JPEG preview window doesn't get closed.
The port had a slight error, because in gimp-2-10, the display_ID
actually had 3 states: 0 when gimp_export_image() kept the original
image to which we just add a preview layer, -1 when it created a new
image which we wanted to put in its own display, and the display ID
itself when created.

With the new API where display variable is an object, we can only have 2
cases. So I create an additional variable separate_display to make the
distinction.
2021-04-30 01:35:51 +02:00
Jehan 823ae50cc5 plug-ins: fix crash at end of JPEG export.
Not sure why we didn't see the crash earlier and it suddenly shows up
now. Anyway we must delete the exported image **after** calling
gimp_procedure_config_end_export() on it, obviously.
2021-01-17 21:53:48 +01:00
Jehan b13502088f libgimp, plug-ins: add a "format name" concept to GimpFileProcedure.
This format name is a public facing name for a file format, such as
"PNG", "JPEG", or "C-source". Since it is public facing, the function
recommends to localize it too.
This is an optional name, yet is made mandatory if you want to use
GimpSaveProcedureDialog because it will be used for the dialog title
(ensuring that all support format have a similar export dialog title).
Following this change, gimp_save_procedure_dialog_new() does not ask for
a title anymore (if anyone absolutely wants to set a custom title,
setting the "title" property on the dialog is always possible anyway,
but a generic and consistent title should be set as a default).

Also updating the 3 plug-ins which were already using the now-changed
API.
2020-12-17 02:13:43 +01:00
Jehan 222c820024 libgimp, plug-ins: make mnemonic unique.
The various generic metadata options did not have mnemonic in the base
language (US English).
Also add or fix metadata in file-png|jpeg|tiff so that every option has
a unique mnemonic.
2020-11-26 01:37:17 +01:00
Jehan 731537befd plug-ins: port file-jpeg export procedure to new API.
This is nearly 600 lines less for basically the same logics! Removed
code is in particular all the GUI code is favor of the new GUI
generation.
I also cleaned a lot of stuff, removing many global variables or ugly
pieces of code. I also removed a lot of redundant code of things which
are now generic, such as handling of "gimp-comment" parasite (this is
now handled by GimpSaveProcedure and GimpImageMetadata) as well as
saving previous run's values (this is also handled generically).

Note that Advanced Options used to be in an expander. For now I chose to
get them immediately visible (still in their own "Advanced Options"
section, but it's now a normal frame, not an expander hidden by default)
since lately we got some input that many "advanced options" in various
dialogs should not be hidden away. So let's try like this for now (even
though it packs quite a lot of options in the same dialog!).

I thoroughly tested, yet that were so many changes that bugs may have
sneaked in. Please anyone, test JPEG export!
2020-11-25 23:02:36 +01:00
Jacob Boerema fafe9889e0 plug-ins: Let the user know if we fail to save image metadata in file-jpeg. 2020-10-15 15:12:58 -04:00
Jehan 67e2e1b5bb app, libgimp, plug-ins: move Orientation metadata handling into core.
Orientation is now handled by core code, just next to profile conversion
handling.

One of the first consequence is that we don't need to have a non-GUI
version gimp_image_metadata_load_finish_batch() in libgimp, next to a
GUI version of the gimp_image_metadata_load_finish() function in
libgimpui. This makes for simpler API.
Also a plug-in which wishes to get access to the rotation dialog
provided by GIMP without loading ligimpui/GTK+ (for whatever reason)
will still have the feature.

The main advantage is that the "Don't ask me again" feature is now
handled by a settings in `Preferences > Image Import & Export` as the
"Metadata rotation policy". Until now it was saved as a global parasite,
which made it virtually non-editable once you checked it once (no easy
way to edit parasites except by scripts). So say you refused the
rotation once while checking "Don't ask again", and GIMP will forever
discard the rotation metadata without giving you a sane way to change
your mind. Of course, I could have passed the settings to plug-ins
through the PDB, but I find it a lot better to simply handle such
settings core-side.

The dialog code is basically the same as an app/dialogs/ as it was in
libgimp, with the minor improvement that it now takes the scale ratio
into account (basically the maximum thumbnail size will be bigger on
higher density displays).

Only downside of the move to the core is that this rotation dialog is
raised only when you open an image from the core, not as a PDB call. So
a plug-in which makes say a "file-jpeg-load" PDB call, even in
INTERACTIVE run mode, won't have rotation processed. Note that this was
already the same for embedded color profile conversion. This can be
wanted or not. Anyway some additional libgimp calls might be of interest
to explicitly call the core dialogs.
2020-09-24 12:43:41 +02:00
Jehan 47a68dc871 Issue #5584: JPEG magics detection failure.
Our currently registered JPEG magics was using possible fields at the
start of the file (JFIF, Exif) in 7th byte. A JPEG provided in #5584 was
starting with yet another field (apparently some Photoshop-specific
field "Photoshop 3.0.8BIM") thus magics detection failed (and since
extension was wrong, the file was sent to another plug-in, hence loading
failed).

Looking further, it looks like the 3 first bytes are actually always
common to all JPEG and are the right magics/signature for a JPEG. These
3 bytes don't seem to be used by other formats as well according to my
research, which means we should not have false positives either. So
let's switch to this magics 0XFFD8FF at byte 0.
2020-08-26 12:13:29 +02:00
Jehan d3139e0f7c app: support saving/exporting with multi-selection.
This commit just changes our saving API (i.e. the GimpSaveProcedure
class) to take an array of drawables as argument instead of a single
drawable.

It actually doesn't matter much for exporting as the whole API seems
more or less bogus there and all formats plug-ins mostly care only
whether they will merge/flatten all visible layers (the selected ones
don't really matter) or if the format supports layers of some sort. It
may be worth later strengthening a bit this whole logics, and maybe
allow partial exports for instance.

As for saving, it was not even looking at the passed GimpDrawable either
and was simply re-querying the active layer anyway.
Note that I don't implement the multi-selection saving in XCF yet in
this commit. I only updated the API. The reason is that the current
commit won't be backportable to gimp-2-10 because it is an API break. On
the other hand, the code to save multi-selection can still be backported
even though the save() API will only pass a single drawable (as I said
anyway, this argument was mostly bogus until now, hence it doesn't
matter much for 2.10 logics).
2020-05-17 18:32:16 +02:00
Michael Natterer 991703a7ee plug-ins: minor cleanups in file-jpeg, no porting to new stuff yet 2019-10-23 19:08:33 +02:00
Michael Natterer 9326f4a76c plug-ins: rename all boolean comment arguments to "save-comment"
and let them default to gimp_export_comment(). Set the default value
of all "comment" arguments to gimp_get_default_comment().
2019-10-10 01:32:28 +02:00
Michael Natterer df8d5b02ae libgimp, plug-ins: remove the "preview" parameter from gimp_ui_init()
It's dead since a looong time.
2019-09-20 19:56:00 +02:00
Michael Natterer 6bca8c4f89 pdb, app, libgimp, plug-ins: replace most PDB filenames/URIs by GFile
and in an attack of madness, changes almost all file plug-in
code to use GFile instead of filenames, which means passing
the GFile down to the bottom and get its filename at the very
end where it's actually needed.
2019-09-11 21:48:34 +02:00
Michael Natterer 26a744f44d plug-ins: register thumbnail procedures before load procedures
so registering the thumbnail loader with the load procedure can
perform some checks for procedure existence and signature.
2019-09-10 19:36:54 +02:00
Michael Natterer 8a78203aed Properly prefix the values of enum GimpPDBProcType
to be GIMP_PDB_PROC_TYPE_PLUGIN, _EXTENSION etc.
2019-08-30 12:52:28 +02:00
Michael Natterer 3bef94d56f plug-ins: port file-jpeg to GimpPlugIn and to libgimp objects 2019-08-24 02:33:45 +02:00
Michael Natterer de121374ef Change the "handles uri" flag of file procedures to "handle remote"
And always pass URIs to all file procedures, the ones what didn't
register as "handles remove" will only ever get local file:// URIs.

Change all file plug-ins (also legacy ones) to expect URIs instead
of filenames, and convert to local paths in the plug-in.

The wire protocol should now be almost 100% clean of non-UTF-8 strings.
2019-08-19 12:05:12 +02:00
Michael Natterer c667fdc5c0 Integrate the logic of profile saving with metadata saving
Add flag GIMP_METADATA_SAVE_COLOR_PROFILE to GimpMetadataSaveFlags and
initialize it from gimp_export_color_profile() in
gimp_image_metadata_save_prepare().

Adapt all plug-ins to use the bit from the suggested export flags and
pass the actually used value back to
gimp_image_metadata_save_finish().

This changes no behavior at all but creates hooks on the libgimp side
that are called with the context of an image before and after the
actual export, which might become useful later. Also, consistency
is good even though the color profile is not strictly "metadata".
2018-12-04 17:28:24 +01:00
Michael Natterer 540cfa9611 Issue #1297 - Unhide the items hidden in the Advanced drop-down file...
...export dialogs

Move most stuff out of the "Advanced" expander, only nerdish encoding
options are left there.

Issue #701: Add a "Save color profile" toggle which honors the default
value configured in preferences and always saves the profile when
enabled.
2018-12-03 12:19:41 +01:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
luz.paz 4a77ff2d3d Bug 795557 - Misc. typo fixes in source, comments and doxygen (pt3)
Found via `codespell` and grep.
2018-04-25 23:49:06 +02:00
Jehan 82f6baf2bb plug-ins: file export should follow preferences regarding metadata.
Various plug-ins exporting metadata should now follow preferences, which
would override any default. Of course these preferences can still be
overriden by saved settings (global parasite), previous run settings,
and finally through the GUI when interactive.
2018-01-11 22:17:32 +01:00
Hartmut Kuhse 66bc98d299 Revert "New GimpMetadata as subclass of GExiv2Metadata"
This reverts commit 3ab08c8bfd.
2017-01-03 19:36:22 +01:00
Hartmut Kuhse 3ab08c8bfd New GimpMetadata as subclass of GExiv2Metadata 2017-01-03 19:26:35 +01:00
Mihail Zenkov 07eb13c73d Bug 769976 - JPEG export ignores quality setting and subsampling fix.
Set use_orig_quality when both the quality and the subsampling are the
same as in the originally-imported jpeg.

Also improve subsampling initial selection: use the original subsampling
unless the default one is the best or the original one is the worst.
The current code was wrong and would often use the default subsampling
even when worse than the original one.
2016-11-08 16:09:37 +01:00
Mukund Sivaraman 5c0cdb8ca8 file-jpeg: Improve description of file-jpeg-save args (#738443) 2014-10-20 10:23:00 +05:30
Michael Natterer ac9101691c plug-ins: various small cleanups in the plug-ins that use metadata 2014-06-05 21:33:40 +02:00
Michael Natterer 3a4fedea7c libgimp: make gimp_image_metadata_save_prepare() suggest GimpMetadataSaveFlags
Return flags based on what metadata is actually present in the image.
Returning of a suggested value for GIMP_METADATA_SAVE_THUMBNAIL needs
support from gimp_image_metadata_load_prepare() and is still missing.

Port all plug-ins to use the new API, the suggested values are however
overridden by parasites and whatever special code was devised for the
individual plug-ins. This needs to be fixed.
2014-06-05 02:07:13 +02:00
Michael Natterer 03df8c6af4 plug-ins: pass the format's name again in calls to gimp_export_image()
and clean up the formatting of the call and the lines around it. Now
we can check the various (disabled) export options for regressions
again by changing a single line in gimp_export_image().
2013-11-10 00:18:48 +01:00
Michael Natterer 8812abee0a plug-ins: save the metadata of the orig_image_ID in file-jpeg-save
The image_ID might be an export image and already deleted.
2013-11-05 08:49:40 +01:00
Michael Natterer 7752873add plug-ins: trust the TIFF's resolution over its metadata's resolution
This also sortof addresses bug #691231, but fixes the issue only
indirectly by not perferring the EXIF resolution.
2013-10-27 18:52:46 +01:00
Michael Natterer a44e06d059 plug-ins: reverse the logic for setting GimpMetadataSaveFlags
start with flags = ALL (which now includes all possible current and
future flags), and optionally *remove* individual flags instead of
adding them. This way the plug-ins default to TRUE for future flags.
2013-10-27 15:38:42 +01:00
Michael Natterer 7cbe83d911 libgimp,plug-ins: split metadata loading into prepare() and finish()
So the plug-in has the chance to decide whether it wants to trust the
metadata information (e.g. resolution). Also reorder parameters in
gimp_image_metadata_save_finish(). Change all plug-ins accordingly.
2013-10-27 15:22:35 +01:00
Hartmut Kuhse 21bed1e2fb Completely rewrite metadata handling using gexiv2
Based on original patches from Hartmut Kuhse and modified
by Michael Natterer. Changes include:

- remove libexif dependency and add a hard dependency on gexiv2
- typedef GExiv2Metadata to GimpMetadata to avoid having to
  include gexiv2 globally
- add basic GimpMetadata handling functions to libgimpbase
- add image and image file specific metadata functions to libgimp,
  including the exif orientation image rotate dialog
- port plug-ins to use the new APIs
- port file-tiff-save's UI to GtkBuilder
- add new plug-in "metadata" to view the image's metadata
- keep metadata around as GimpImage member in the core
- update the image's metadata on image size, resolution and precision
  changes
- obsolete the old metadata parasites
- migrate the old parasites to new GimpMetadata object on XCF load
2013-10-27 01:02:17 +02:00
Mukund Sivaraman 51680fb987 file-jpeg: GEGL convert load functions
drawable_global doesn't seem to be used anywhere. This commit removes
it.
2013-05-13 11:42:10 +05:30
Michael Natterer f888792a77 plug-ins: return image type and #layers from the JPEG thumbnail procedure 2012-05-02 17:51:03 +02:00
Mukund Sivaraman aa2a876d22 file-jpeg: Rename load_save_defaults() to load_defaults() 2011-09-30 18:31:27 +05:30
Mukund Sivaraman bd3faae04c file-jpeg: Include gimpexif.h only if HAVE_LIBEXIF 2011-09-18 08:08:16 +05:30
Mukund Sivaraman 536d6a527c file-jpeg: Create jpeg-exif.h and move EXIF protos to it 2011-09-18 07:21:30 +05:30
Mukund Sivaraman 2aae54226c build: Rename HAVE_EXIF define to HAVE_LIBEXIF 2011-09-18 07:04:44 +05:30
Mukund Sivaraman 0a20d9bdbd file-jpeg: Rename misnamed macros 2011-06-10 23:40:23 +05:30
Mukund Sivaraman 4e0a48fabc file-jpeg: (save) Change the label for restart interval
This was discussed in #gimp. The old label was "Frequency (rows)"
which is misleading. This field is basically converted by libjpeg
to another value called a restart interval which is stored in a
JPEG file. The restart interval specifies after how many MCUs
the restart (syncronization) marker appears in the bitstream.
It is not easy to explain to a layperson what an MCU is.

The value in the dialog specifies after how many *MCU rows* the
restart marker appears. This is a libjpeg thing, and libjpeg
converts it to the restart interval.

I have merely renamed the text label of the field and PDB
description as the current text implies pixel rows which is not
the case.

A better alternative is to use the restart interval (in MCUs,
not MCU rows) as saved in the file itself, which more people
than users of libjpeg would understand. But even that setting
is not something that can easily be explained to a layperson.
2011-06-10 23:33:11 +05:30
Michael Natterer 87646e9ace libgimp: deprecate and rename the image parasite functions
in exactly the way the drawable functios were turned into item ones.
2011-03-08 13:19:21 +01:00
Massimo Valentini fc979283de Bug 569833 – file-jpeg-save erroneous with small quality values
Use the passed parameters if the quality setting is 0.01 or greater
instead of rejecting values below 0.05 in non-interactive mode.
2009-08-10 21:26:53 +02:00
Martin Nordholts 19fe919dce plug-ins: Port file plug-ins to new export API 2009-07-21 16:03:58 +02:00
Michael Natterer 4ea1437646 plug-ins/common/*.c plug-ins/color-rotate/color-rotate.c
2009-01-19  Michael Natterer  <mitch@gimp.org>

	* plug-ins/common/*.c
	* plug-ins/color-rotate/color-rotate.c
	* plug-ins/file-bmp/bmp.c
	* plug-ins/file-faxg3/faxg3.c
	* plug-ins/file-fits/fits.c
	* plug-ins/file-fli/fli-gimp.c
	* plug-ins/file-ico/ico.c
	* plug-ins/file-jpeg/jpeg.c
	* plug-ins/file-psd/psd-save.c
	* plug-ins/file-psd/psd.c
	* plug-ins/file-sgi/sgi.c
	* plug-ins/file-uri/uri.c
	* plug-ins/file-xjt/xjt.c
	* plug-ins/flame/flame.c
	* plug-ins/fractal-explorer/fractal-explorer.c
	* plug-ins/gfig/gfig.c
	* plug-ins/gimpressionist/gimp.c
	* plug-ins/gradient-flare/gradient-flare.c
	* plug-ins/help-browser/help-browser.c
	* plug-ins/ifs-compose/ifs-compose.c
	* plug-ins/imagemap/imap_main.c
	* plug-ins/lighting/lighting-main.c
	* plug-ins/map-object/map-object-main.c
	* plug-ins/maze/maze.c
	* plug-ins/metadata/metadata.c
	* plug-ins/pagecurl/pagecurl.c
	* plug-ins/print/print.c
	* plug-ins/pygimp/gimpfu.py
	* plug-ins/script-fu/script-fu-script.c
	* plug-ins/script-fu/script-fu.c
	* plug-ins/selection-to-path/selection-to-path.c
	* plug-ins/twain/twain.c
	* plug-ins/win-snap/winsnap.c: document the "run-mode" parameter
	as we document enums for core procedures.


svn path=/trunk/; revision=27922
2009-01-19 20:11:36 +00:00