Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Macao Legacy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MACAO
Macao Legacy
Commits
0fd0ef9a
Commit
0fd0ef9a
authored
1 month ago
by
David Rouquet
Browse files
Options
Downloads
Patches
Plain Diff
crop images
parent
5e9d6cc7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tetras_extraction/script/cropImages.sh
+31
-0
31 additions, 0 deletions
tetras_extraction/script/cropImages.sh
with
31 additions
and
0 deletions
tetras_extraction/script/cropImages.sh
0 → 100644
+
31
−
0
View file @
0fd0ef9a
#!/bin/bash
# Check if the directory is provided as an argument
if
[
-z
"
$1
"
]
;
then
echo
"Usage:
$0
<directory>"
exit
1
fi
# Get the directory from the first argument
DIRECTORY
=
$1
# Check if the provided argument is a directory
if
[
!
-d
"
$DIRECTORY
"
]
;
then
echo
"Error:
$DIRECTORY
is not a valid directory."
exit
1
fi
# Recursively iterate over files in the directory
find
"
$DIRECTORY
"
-type
f |
while
read
-r
filepath
;
do
# Check if the file is an image
file_type
=
$(
file
--mime-type
-b
"
$filepath
"
)
if
[[
$file_type
==
image/
*
]]
;
then
# Apply the magick convert command with -trim option
magick convert
"
$filepath
"
-trim
"
$filepath
"
echo
"Processed:
$filepath
"
else
echo
"Skipped (not an image):
$filepath
"
fi
done
echo
"All files processed."
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment