Convert creates multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert creates multiple files
# 8  
Old 12-10-2018
Stupid question: What do you get if you type
Code:
identify mountain.png

Maybe the output of that will give a clue as to why you get four files from the convert command.

Andrew
# 9  
Old 12-10-2018
Quote:
Originally Posted by Kangol
The problem is that convert is creating 4 files

Code:
mountain--cr-0.png
mountain--cr-1.png
mountain--cr-2.png
mountain--cr-3.png

The first is what I need, the other look empty
OK, but what is the problem? Throw away the other 3 if you don't need them. Or do you want to autmate the process? If so, it would be nice to know your OS, your shell, ... you now the drill. Supposing you can use Korn shell and your system has the standard features how about this:

Code:
bakunin@host $ cat myconvert.sh
#! /bin/ksh
typeset fIn="$1"
typeset chExt=".png"
fIn="${fIn#${chExt}}"

if ! [ -f "${fIn}.${chExt}" ; then
     print -u2 "Cannot find file ${fIn}.${chExt}."
     exit 1
fi
if convert "$fIn.$chExt" -crop 3000x4500 +repage -format png "${fIn}--cr.${chExt}" ; then
     rm "${fIn}-cr-1.${chExt}"
     rm "${fIn}-cr-2.${chExt}"
     rm "${fIn}-cr-3.${chExt}"
     mv "${fIn}-cr-0.${chExt}" "${fIn}-cr.${chExt}"
     exit 0
fi

exit $?

I hope this helps.
# 10  
Old 12-10-2018
I prefer not to resize the image.


I have a canvas of size 3583 Ã- 5049 pixels. The image within the png file is 2944x4454.


Just want to crop to 3000x4500, perhaps fill the background with white for the area outside the image

--- Post updated at 03:13 PM ---

Quote:
Originally Posted by apmcd47
Stupid question: What do you get if you type
Code:
identify mountain.png

Maybe the output of that will give a clue as to why you get four files from the convert command.

Andrew

I get



mountain.png PNG 3583x5049 3583x5049+0+0 8-bit DirectClass 912KB 0.000u 0:00.000

--- Post updated at 03:18 PM ---

Quote:
Originally Posted by bakunin
OK, but what is the problem? Throw away the other 3 if you don't need them. Or do you want to autmate the process? If so, it would be nice to know your OS, your shell, ... you now the drill. Supposing you can use Korn shell and your system has the standard features how about this:

Code:
bakunin@host $ cat myconvert.sh
#! /bin/ksh
typeset fIn="$1"
typeset chExt=".png"
fIn="${fIn#${chExt}}"

if ! [ -f "${fIn}.${chExt}" ; then
     print -u2 "Cannot find file ${fIn}.${chExt}."
     exit 1
fi
if convert "$fIn.$chExt" -crop 3000x4500 +repage -format png "${fIn}--cr.${chExt}" ; then
     rm "${fIn}-cr-1.${chExt}"
     rm "${fIn}-cr-2.${chExt}"
     rm "${fIn}-cr-3.${chExt}"
     mv "${fIn}-cr-0.${chExt}" "${fIn}-cr.${chExt}"
     exit 0
fi

exit $?

I hope this helps.

GNU Trisquel 7.0 with Gnome Version 3.8.4running bash


The task is to understand how it is creating the additional files, what are they? Has anybody encountered them before?
I also want to understand if my image is created properly. Are the headers correct, offset etc

--- Post updated at 03:26 PM ---

I now have tried, seem to work. Would this be ok, or do aybody have better suggestions?



Code:
convert mountain.png -format png -background white -flatten -crop 3000x4500 +repage mountain--cr.png

# 11  
Old 12-10-2018
Quote:
Originally Posted by Kangol
GNU Trisquel 7.0 with Gnome Version 3.8.4running bash
Well, in this the bash version. You see why it is necessary to state your surroundings?

Code:
bakunin@host $ cat myconvert.sh
#! /bin/bash
local fIn="$1"
local chExt=".png"
fIn="${fIn#${chExt}}"

if ! [ -f "${fIn}.${chExt}" ; then
     echo "Cannot find file ${fIn}.${chExt}." >&2
     exit 1
fi
if convert "$fIn.$chExt" -crop 3000x4500 +repage -format png "${fIn}--cr.${chExt}" ; then
     rm "${fIn}-cr-1.${chExt}"
     rm "${fIn}-cr-2.${chExt}"
     rm "${fIn}-cr-3.${chExt}"
     mv "${fIn}-cr-0.${chExt}" "${fIn}-cr.${chExt}"
     exit 0
fi

exit $?

Quote:
Originally Posted by Kangol
The task is to understand how it is creating the additional files, what are they? Has anybody encountered them before?
I also want to understand if my image is created properly. Are the headers correct, offset etc
This is a question best asked an expert in picture processing. I have never used this (or any other picture processing) program at all.

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep strings on multiple files and output to multiple files

Hi All, I want to use egrep on multiple files and the results should be output to multiple files. I am using the below code in my shell script(working in Ksh shell). However with this code I am not attaining the desired results. #!/bin/ksh ( a="/path/file1" b="path/file2" for file in... (4 Replies)
Discussion started by: am24
4 Replies

2. Shell Programming and Scripting

Convert single column into multiple rows

Convert Single column to multiple rows file a.txt contains data like below Server=abc Run=1 Tables=10 Sessions=16 Time=380 Jobs=5 Server=abc Run=2 Tables=15 Sessions=16 Time=400 Jobs=5 Server=abc Run=3 Tables=20 Sessions=16 Time=450 (5 Replies)
Discussion started by: sol_nov
5 Replies

3. UNIX for Advanced & Expert Users

Allow user without dir write permission to execute a script that creates files

In our project we have several unix scripts that trigger different processes. These scripts write logs to a particular folder 'sesslogs', create output data files in a separate directory called 'datafiles' etc. Usually L1 support team re-run these scripts . We donot want L1 support team to have... (14 Replies)
Discussion started by: waavman
14 Replies

4. Shell Programming and Scripting

How to convert multiple number ranges into sequence?

Looking for a simple way to convert ranges to a numerical sequence that would assign the original value of the range to the individual numbers that are on the range. Thank you given data 13196-13199 0 13200 4 13201 10 13202-13207 3 13208-13210 7 desired... (3 Replies)
Discussion started by: jcue25
3 Replies

5. Shell Programming and Scripting

awk, multiple files input and multiple files output

Hi! I'm new in awk and I need some help. I have a folder with a lot of files and I need that awk do something in each file and print a new file with the output. The input file name should be modified when I print the outpu files. Thanks in advance for help! :-) ciao (5 Replies)
Discussion started by: gabrysfe
5 Replies

6. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

7. Shell Programming and Scripting

Cannot get to convert multiple spaces to one space

Hi Guys, I am using a Redhat Linux Centos machine and trying to convert multiple spaces in a file to one space. I am using: sed '/./,/^$/!d' input_file > output_file I also tried cat -s Both gave me no change in the output file. I tried this on cygwin and it worked... (7 Replies)
Discussion started by: npatwardhan
7 Replies

8. UNIX for Dummies Questions & Answers

naming files that csplit creates

Hi, This is my first time on this forum.. I searched the previous answers, but didn't find the answer I was looking for at first glance. csplit works beautifully for me, except for one thing. My file looks like this: ad|name1|asdf...(several pages)..asdf ... ad|name2|asdf...(several... (8 Replies)
Discussion started by: juliette salexa
8 Replies

9. UNIX for Dummies Questions & Answers

SCO 5.0.7 Cron creates files with 600, need 644

Hi, I've searched and read, and searched and read some more; but I'm still not connecting the dots or understanding what I need to change. I have a script that creates a file. If I run it as root, the file gets created with 644 permissions like I want. That seems to make sense (at least I... (2 Replies)
Discussion started by: 65bit
2 Replies

10. Windows & DOS: Issues & Discussions

gVim creates and leaves strange tilde ~ files in Windows

Hey folks, I have used gVim in Windows for many years but I have never found an answer to a very simple question I am going to ask you guys... My question is if there is a way to eliminate the creation of those ~ files that gVim creates in Windows. If you have ever used gVim in Windows you... (2 Replies)
Discussion started by: ghbarratt
2 Replies
Login or Register to Ask a Question