Error when converting lots in JPG in BATCH

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
mikarts
Posts: 10
Joined: 2018-04-05T21:30:14-07:00
Authentication code: 1152

Error when converting lots in JPG in BATCH

Post by mikarts »

Morning.
I use a batch archive for resizing lots of JPG. This works:

Code: Select all

for %%F in (*.JPG) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/JPG ORIGINAL"
    convert "%%F" -resize 1500x1000 -strip -quality 90 -interlace plane "%%C-%%B-%%A/%%F"
    move "%%F" "%%C-%%B-%%A/JPG ORIGINAL"
  )
)
But when and I try to not strip the image information it crashes:

Code: Select all

for %%F in (*.JPG) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/JPG ORIGINAL"
    convert "%%F" -resize 1500x1000 -quality 90 -interlace plane "%%C-%%B-%%A/%%F"
    move "%%F" "%%C-%%B-%%A/JPG ORIGINAL"
  )
)
There is only the difference -strip

I have this trouble from a long time.
I have tried with several versions, at least from the 6.9.2, and just now with the
7.0.7-28-Q8-x64
7.0.7-28-Q16-x64
I am working on windos 10 x64

Could someone help me?
Many thanks.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error when converting lots in JPG in BATCH

Post by snibgo »

mikarts wrote:it crashes
What crashes? What error message do you get?

Can you isolate the problem to a single "convert" command, on a single file, with no variables like %%C. Then we can investigate.
snibgo's IM pages: im.snibgo.com
mikarts
Posts: 10
Joined: 2018-04-05T21:30:14-07:00
Authentication code: 1152

Re: Error when converting lots in JPG in BATCH

Post by mikarts »

Sorry, I have now more information.
This code is part of a batch which classifies different kind of archives, like PSD, DNG, MOV, etc.
If I isolate this code in a single BATCh everything works. The trouble appears when it is in the full BATCH I copy now its code:

Code: Select all

REM JPG CLASIFICA Y COMPRIME A 90
for %%F in (*.JPG) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/JPG ORIGINAL"
    convert "%%F" -resize 1500x1000 -quality 90 -interlace plane "%%C-%%B-%%A/%%F"
    move "%%F" "%%C-%%B-%%A/JPG ORIGINAL"
  )
)
REM PSD
for %%F in (*.PSD) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/PSD"
    move "%%F" "%%C-%%B-%%A/PSD"
  )
)
REM RAW
for %%F in (*.NEF) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/DNG"
    move "%%F" "%%C-%%B-%%A/DNG"
  )
)
for %%F in (*.CR2) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/DNG"
    move "%%F" "%%C-%%B-%%A/DNG"
  )
)
for %%F in (*.DNG) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/DNG"
    move "%%F" "%%C-%%B-%%A/DNG"
  )
)
REM VÍDEOS
for %%F in (*.MOV) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/MOV"
    move "%%F" "%%C-%%B-%%A/MOV"
  )
)
for %%F in (*.3GP) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/3GP"
    move "%%F" "%%C-%%B-%%A/3GP"
  )
)
for %%F in (*.MP4) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/MP4"
    move "%%F" "%%C-%%B-%%A/MP4"
  )
)
for %%F in (*.MTS) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/MTS"
    move "%%F" "%%C-%%B-%%A/MTS"
  )
)
for %%F in (*.AVI) do (
  for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
    md "%%C-%%B-%%A"
    md "%%C-%%B-%%A/AVI"
    move "%%F" "%%C-%%B-%%A/AVI"
  )
)
del Convert.bat
The error is (in spanish):
Procesador de comandos de Windows
Procesador de comandos de Windows dejó de funcionar
El programa dejó de funcionar correctamente por un problema. Windows cerrará el programa y le notificará si existe una solución.
Cerrar programa

The last is a button. When I press it directly closes the DOS Window.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error when converting lots in JPG in BATCH

Post by snibgo »

That isn't an error from ImageMagick, but a generic Windows message that something fatal has happened. Does this happen with all JPEGs? Or just large ones?
snibgo's IM pages: im.snibgo.com
mikarts
Posts: 10
Joined: 2018-04-05T21:30:14-07:00
Authentication code: 1152

Re: Error when converting lots in JPG in BATCH

Post by mikarts »

Thank you.
It happens with all JPG.

I do not why, but if you change the line
convert "%%F" -resize 1500x1000 -quality 90 -interlace plane "%%C-%%B-%%A/%%F"
by this other
convert "%%F" -resize 1500x1000 -strip -quality 90 -interlace plane "%%C-%%B-%%A/%%F"
The bat works till the end. Never crashes.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error when converting lots in JPG in BATCH

Post by fmw42 »

Your profiles and other meta data may be very large or corrupt and so needs to be stripped.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error when converting lots in JPG in BATCH

Post by snibgo »

Please post a link to an example JPEG that gives the problem.
snibgo's IM pages: im.snibgo.com
mikarts
Posts: 10
Joined: 2018-04-05T21:30:14-07:00
Authentication code: 1152

Re: Error when converting lots in JPG in BATCH

Post by mikarts »

I have tried with stripped JPGs an remains without working.
And this works in a single .bat:
for %%F in (*.JPG) do (
for /f "tokens=1-3 delims=/ " %%A in ("%%~tF") do (
md "%%C-%%B-%%A"
md "%%C-%%B-%%A/JPG ORIGINAL"
convert "%%F" -resize 1500x1000 -strip -quality 90 -interlace plane "%%C-%%B-%%A/%%F"
move "%%F" "%%C-%%B-%%A/JPG ORIGINAL"
)
)
The trouble appears when you add the other parts of the batch and only with the strip.
I cannot understand why.
mikarts
Posts: 10
Joined: 2018-04-05T21:30:14-07:00
Authentication code: 1152

Re: Error when converting lots in JPG in BATCH

Post by mikarts »

In my experience any JPG gives the problem.
mikarts
Posts: 10
Joined: 2018-04-05T21:30:14-07:00
Authentication code: 1152

Re: Error when converting lots in JPG in BATCH

Post by mikarts »

In my experience any JPG gives the problem.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error when converting lots in JPG in BATCH

Post by snibgo »

What command fails?
snibgo's IM pages: im.snibgo.com
mikarts
Posts: 10
Joined: 2018-04-05T21:30:14-07:00
Authentication code: 1152

Re: Error when converting lots in JPG in BATCH

Post by mikarts »

mikarts wrote: 2018-04-05T23:03:32-07:00 Thank you.
It happens with all JPG.

I do not why, but if you change the line
convert "%%F" -resize 1500x1000 -quality 90 -interlace plane "%%C-%%B-%%A/%%F"
by this other
convert "%%F" -resize 1500x1000 -strip -quality 90 -interlace plane "%%C-%%B-%%A/%%F"
The bat works till the end. Never crashes.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error when converting lots in JPG in BATCH

Post by snibgo »

Yes, but how far does the batch file get when the failure happens?
snibgo's IM pages: im.snibgo.com
mikarts
Posts: 10
Joined: 2018-04-05T21:30:14-07:00
Authentication code: 1152

Re: Error when converting lots in JPG in BATCH

Post by mikarts »

The bat works creatting the directories and moving the archives different of JPG to its directory. Then batch crashes when it tries to convert the first JPG.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error when converting lots in JPG in BATCH

Post by fmw42 »

Perhaps update your libjpeg delegate.
Post Reply