pa_rotate (public)

 pa_rotate id rotation

Defined in packages/photo-album/tcl/photo-album-procs.tcl

Rotate a pic

Parameters:
id - the photo_id to rotate
rotation - the number of degrees to rotate
Author:
Jeff Davis davis@xarg.net
Created:
2002-10-30

Partial Call Graph (max 5 caller/called nodes):
%3 packages/photo-album/www/photo-edit.tcl packages/photo-album/ www/photo-edit.tcl pa_rotate pa_rotate packages/photo-album/www/photo-edit.tcl->pa_rotate packages/photo-album/www/photos-edit-2.tcl packages/photo-album/ www/photos-edit-2.tcl packages/photo-album/www/photos-edit-2.tcl->pa_rotate cr_fs_path cr_fs_path (private) pa_rotate->cr_fs_path db_dml db_dml (public) pa_rotate->db_dml db_foreach db_foreach (public) pa_rotate->db_foreach parameter::get parameter::get (public) pa_rotate->parameter::get

Testcases:
No testcase defined.
Source code:
    if {$rotation ne "" && $rotation ne "0" } { 
        set flop [list]
        set files [list]

        # get a list of files to handle sorted by size...
        db_foreach get_image_files {} {
            ns_log Debug "pa_rotate: rotate $id by $rotation [cr_fs_path$filename $image_id $width $height"
            if {[catch {exec [parameter::get -parameter ImageMagickPath]/convert -rotate $rotation [cr_fs_path]$filename [cr_fs_path]${filename}.new } errMsg]} { 
                ns_log Warning "pa_rotate: failed rotation of image $image_id -- $errMsg"
            }
            lappend flop $image_id
            lappend files [cr_fs_path]$filename
        }

        # rename files in catch.
        if { [catch { 
            foreach fnm $files {
                file rename -force $fnm ${fnm}.old 
                file rename -force ${fnm}.new $fnm
            } } errMsg ] } { 
            # problem with the renaming.  Make an attempt to rename them back 
            catch { 
                foreach fnm $files {
                    file rename -force ${fnm}.old $fnm
                    file delete -force ${fnm}.new
                }
            } errMsg
        } else { 
            # flop images that need flopping.
            if {$rotation eq "90" || $rotation eq "270"} { 
                db_dml flop_image_size "update images set width = height, height = width where image_id in ([join $flop ,])"
            }
        }
    }
Generic XQL file:
<fullquery name="pa_rotate.get_image_files">
    <querytext>
      
            select i.image_id, crr.content as filename, i.width, i.height
            from cr_items cri, cr_revisions crr, images i
            where cri.parent_id = :id
              and crr.revision_id = cri.latest_revision
              and i.image_id = cri.latest_revision
            order by crr.content_length desc
        
      </querytext>
</fullquery>
packages/photo-album/tcl/photo-album-procs.xql

PostgreSQL XQL file:
packages/photo-album/tcl/photo-album-procs-postgresql.xql

Oracle XQL file:
packages/photo-album/tcl/photo-album-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: