Anonymous

User:AndyE: Difference between revisions

From London Hackspace Wiki
2,533 bytes removed ,  13 January 2011
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
TODO: put something decent on this page. :)
[[File:Photo-andy.jpg]]


Joined October 2010.
Joined October 2010.
Line 13: Line 13:
The Landy [[File:AndysLandy.JPG]] is potentially available for interesting vehicle-related projects, or just for moving kit. She's a 1978 Series III with added 2" suspension lift, big wheels and 3.5 V8 engine. Standard towbar ball and electrics.
The Landy [[File:AndysLandy.JPG]] is potentially available for interesting vehicle-related projects, or just for moving kit. She's a 1978 Series III with added 2" suspension lift, big wheels and 3.5 V8 engine. Standard towbar ball and electrics.


''''Project EngraveAtDifferentDepths''''
'''Projects'''


one
[[Projects/Script_for_splitting_images_so_we_can_use_the_laser_cutter_to_engrave_them_in_greyscale]]
<pre>
 
#!/usr/bin/perl -w
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
 
my $q = CGI->new();
 
print $q->header;
print $q->start_html;
 
print $q->p("this is a thing for doing threshholding");
print $q->p("<small>or possibly <i>thresholding</i>?</small>");
 
print $q->start_form( -enctype => "multipart/form-data" );
 
print $q->p("threshhold start? (0-100)");
print $q->textfield('tval');
print $q->p("threshold interval?");
print $q->textfield('tinterval');
print $q->p("file");
print $q->filefield('uploaded_file');
print $q->submit();
 
print $q->end_form;
 
# do we have an upload?
my $filehandle = $q->upload('uploaded_file');
if (defined $filehandle) {
 
    # do shit
    print $q->p("I'm doing shit");
 
    # no, actually do shit
    my ($filename) = ($q->param('uploaded_file') =~ /^(\w+)$/);
    my $tempfile = $q->tmpFileName($filename);
 
    my ($tval) = ($q->param('tval') =~ /^(\d+)$/); # only allow digits
    my ($tinterval) = ($q->param('tinterval') =~ /^(\d+)$/); # also only allow digits
 
    for (my $i = $tval; $i <= 100; $i += $tinterval) {
        my @ar = ("gm", "convert", "-threshold", $i."%", $tempfile, "/var/www/threshold_output/$filename".$i);
        system(@ar) == 0 or carp "system call failed: $?"; #safer than passing a string to system()
        print $q->img({src => "/threshold_output/$filename".$i});
    }
}
 
 
print $q->end_html;
 
</pre>
 
 
two
 
 
<pre>
 
#!/usr/bin/perl -w
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
 
my $q = CGI->new();
 
print $q->header;
print $q->start_html;
 
print $q->p("this is a thing for doing threshholding");
print $q->p("<small>or possibly <i>thresholding</i>?</small>");
 
print $q->start_form( -enctype => "multipart/form-data" );
 
print $q->p("threshhold value? (0-100)");
print $q->textfield('tval');
print $q->p("file");
print $q->filefield('uploaded_file');
print $q->submit();
 
print $q->end_form;
 
# do we have an upload?
my $filehandle = $q->upload('uploaded_file');
if (defined $filehandle) {
 
    # do shit
    print $q->p("I'm doing shit");
 
    # no, actually do shit
    my ($filename) = ($q->param('uploaded_file') =~ /^(\w+)$/);
    my $tempfile = $q->tmpFileName($filename);
 
    my ($tval) = ($q->param('tval') =~ /^(\d+)$/); # only allow digits
 
    my @ar = ("gm", "convert", "-threshold", $tval."%", $tempfile, "/var/www/threshold_output/$filename");
    system(@ar) == 0 or carp "system call failed: $?"; #safer than passing a string to system()
 
    print $q->img({src => "/threshold_output/$filename"});
}
 
 
print $q->end_html;
 
 
 
 
 
 
</pre>
105

edits