Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7802431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:15:48+00:00 2026-06-02T01:15:48+00:00

thanks for reading. I’m having performance issues with a script I’ve written that performs

  • 0

thanks for reading. I’m having performance issues with a script I’ve written that performs an ImageMagick compare.

This is the script:

#!/bin/sh

find */ -name '*.tif' > temp-tif-list.txt

FILE="temp-tif-list.txt"

exec 3<&0
exec 0<$FILE
while read line
do
    J2K=`echo "$line" | sed 's/.tif/.jp2/'`
    PSNR=`compare -quiet -metric psnr $line $J2K null: 2>&1 | cut -d . -f 1`
    VALUE=45
    if [ "$PSNR" -le "$VALUE" ]
    then
        echo "possible problem with $line... compare value is $PSNR" >> visual-check.txt
        continue
    fi
done
echo "Deleting generated files..."
rm -f temp-tif-list.txt
exec 0<&3

this script is being run against a directory structure that looks something like this:

    foo/
        foo-1.tif
        foo-1.jp2
        foo-2.tif
        foo-2.jp2
    foo2/
        foo2-1.tif
        foo2-1.jp2
        foo2-2.tif
        foo2-2.jp2
    ...
    ...
    etc

Everything goes wrong pretty quickly; once the script starts the compare on foo-1.tif and foo-1.jp2 it seems to hang (CPU jumps to 799%). Any suggestions are greatly appreciated!

Cheers!

EDIT: ImageMagick was getting stuck on TIFFs with multiple pages. Changing the following

    PSNR=`compare -quiet -metric psnr $line $J2K null: 2>&1 | cut -d . -f 1`

to

    PSNR=`compare -quiet -metric psnr $line[0] $J2K null: 2>&1 | cut -d . -f 1`

seems to be the way towards a slightly more functional script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:15:49+00:00Added an answer on June 2, 2026 at 1:15 am

    Somehow, some of the TIFFs I working with have multiple page images. Until I can determine why that’s happening, the work-around looks something like this:

    compare -metric psnr TIFF-NAME-TIF[0] DERIVATIVE-NAME-EXT 
    

    the [0] tells ImageMagick to use the first page of the TIFF.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guy's First of all thanks for reading this. I'm having trouble to find
Thanks for reading this I thought I could use find(), but couldn't make it
Thanks for reading. On my homepage I've made an script that loops thru a
A happy newyear to all! thanks for reading this! I'm having problems positioning dynamic
Thanks for reading this. I am dynamically generating some data which includes a select
Thanks for reading this. I have markup similar to what is below. Using the
Thanks in Advance for reading and answer this question. I got button in asp
thanks for reading! Here's what I'm up to. I'm writing a WordPress plugin that
Thanks for reading this. I have 2 MySQL databases - master for writes, slave
Hi and thanks for reading this. I am trying to use the IF EXISTS/IF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.