LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-20-2008, 03:28 AM   #1
gcclinux
Member
 
Registered: Oct 2004
Location: London, UK
Distribution: Suse 12.1
Posts: 79

Rep: Reputation: 15
Question Converting a Script from SHELL to PHP


Hello,

I have changed ISP and now I can no longer use PHP system call to call my shell script, so I was wondering if anyone could help me convert it to PHP.

Code:
--------------------------------------------------------------------
First Script is:
--------------------------------------------------------------------

#!/bin/bash
#
# A simple BASH script to use ImageMagick to create a pretty thumbnail
# from the source image as well as scaling the original and placing them
# both in the correct folders.
# name = make_thumb.sh
#
set -x

# Ensure that /usr/local/bin is in the PATH, as ICDSoft removed it without
# notice :o(
export PATH=$PATH:/usr/local/bin

SRC=$1
NAME=$2
DOT=/home/PATH/inc/dot.jpg
TEMP=/home/PATH/www/tmp/$$.jpg

function FN_shadow
{
  FSP=$1
  SRC_SIZE=`identify $FSP | cut -f3 -d' '`
  convert -scale ${SRC_SIZE}!  -border 9x9 -bordercolor white $DOT $TEMP
  mogrify -blur 7x7 $TEMP
  composite -geometry +7+6 $FSP $TEMP $FSP
  chmod 666 $FSP
}

ORIGINAL=/home/PATH/www/photos/originals/$NAME
THUMB=/home/PATH/www/photos/thumbs/$NAME

# Resize image to correct directories
convert -scale 478x358 -border 1x1 -bordercolor black "$SRC" $ORIGINAL
convert -scale 118x118 -border 1x1 -bordercolor black "$SRC" $THUMB
FN_shadow $ORIGINAL
FN_shadow $THUMB

--------------------------------------------------------------------
Second Script is:
--------------------------------------------------------------------



#!/bin/bash
#
# A simple BASH script to use ImageMagick to create rotate an original
# image, and then regenerate the thumbnail.
# name = rotate.sh
#
#set -x

# Ensure that /usr/local/bin is in the PATH, as ICDSoft removed it without
# notice :o(
export PATH=$PATH:/usr/local/bin

SRC=$1
DEGREE=$2
DOT=/home/PATH/inc/dot.jpg
TEMP=/home/PATH/www/tmp/$$.jpg

function FN_shadow
{
  FSP=$1
  SRC_SIZE=`identify $FSP | cut -f3 -d' '`
  convert -scale ${SRC_SIZE}!  -border 9x9 -bordercolor white $DOT $TEMP
  mogrify -blur 7x7 $TEMP
  composite -geometry +7+6 $FSP $TEMP $FSP
  chmod 666 $FSP
}

function FN_rotate
{
  FSP=$1
  RESX=`identify $FSP | cut -f3 -d' ' | sed 's/^\([^x]*\).*/\1/g'`
  RESY=`identify $FSP | cut -f3 -d' ' | sed 's/^[^x]*x\([^+]*\).*/\1/g'`
  mogrify -crop $(($RESX-18))x$(($RESY-18))+7+6 -rotate $DEGREE "$FSP" 
  FN_shadow $FSP
}

ORIGINAL=/home/PATH/www/photos/originals/$SRC
THUMB=/home/PATH/www/photos/thumbs/$SRC

# Rotate thumbnail and original
FN_rotate $ORIGINAL
FN_rotate $THUMB
If anyone could help me I would be very much appreciated!

Regards,

Ricardo
 
Old 02-20-2008, 10:00 AM   #2
rubadub
Member
 
Registered: Jun 2004
Posts: 233

Rep: Reputation: 33
you can use imagemagick directly from php, here's the title page with a list of the available functions, http://uk3.php.net/manual/en/ref.imagick.php, on the other hand you could use the GD library if imagemagick isn't available on your isp...
 
Old 02-21-2008, 05:08 AM   #3
gcclinux
Member
 
Registered: Oct 2004
Location: London, UK
Distribution: Suse 12.1
Posts: 79

Original Poster
Rep: Reputation: 15
Thanks for your response, unfortunately I can no longer any system calls so imagemagick is not a option, I need to be using the GD library, but I would not know how to convert my script to php using GD as I lost contact with the PHP guy that helped me build the page.

Any help would be much appreciated.
 
Old 02-21-2008, 05:51 AM   #4
learnq
LQ Newbie
 
Registered: Jan 2008
Posts: 10

Rep: Reputation: 0
sent email to you.
 
  


Reply

Tags
php, scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script for converting filenames to proper case? Yalla-One Programming 9 02-03-2010 02:37 AM
php/shell script to install mysql,apache and php automatically stranger_6_7 Linux - General 2 08-11-2009 02:07 AM
shell script/command for converting columns/table onto a single line skuz_ball Programming 9 11-30-2007 03:02 AM
PHP -- How to execute a shell script from PHP using FTP functions?? zoonalex Programming 3 07-29-2004 11:51 AM
converting shell script to php script ? ibro Linux - General 6 05-24-2004 05:19 AM


All times are GMT -5. The time now is 01:56 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration