Professional Web Applications Themes

Stupid Question - PERL Beginners

For as long as I've been doing Elements, I'm embarassed to ask. I've created an oval shaped image. I want to insert it into a web page as an oval picture. I can't get rid of the background. I select the areas surrounding the oval and cut it, hoping to have transparency surrounding the picture. Whatever I do-manipulating layers, after I convert it to a Jpeg and insert it into the web page, it comes out as an oval on a white background. OK! I know you're loving forgiving people. Al...

  1. #1

    Default Stupid Question

    For as long as I've been doing Elements, I'm embarassed to ask.

    I've created an oval shaped image. I want to insert it into a web page as an oval picture. I can't get rid of the background. I select the areas surrounding the oval and cut it, hoping to have transparency surrounding the picture. Whatever I do-manipulating layers, after I convert it to a Jpeg and insert it into the web page, it comes out as an oval on a white background.

    OK! I know you're loving forgiving people.

    Al
    Al Millstein Guest

  2. #2

    Default Re: Stupid Question

    I think, going on past posts, that saving as .gif will do the trick.

    (If I'm wrong, I'm sure it will be pointed out) ;)

    Paul
    Paul L UK Guest

  3. #3

    Default Re: Stupid Question

    Paul, you are correct. Gif is the format to chose for keeping transparency ( check 'transparency' option ), however, gif only supports a limited amount of color so your jpeg image will in fact appear degraded. The best work around is to keep it in jpeg format and apply the same background around your oval that is on you webpage if at all possible.
    Jodi Frye Guest

  4. #4

    Default Re: Stupid Question

    Jodi, I think the problem with that is the background space on the picture will interfere with adding additional material to the web page. Maybe I'm overly concerned about that.

    The undesired background is rectangular in shape around the oval. I can try cropping the oval as closely as possible and try to match the two background colors.

    However, it seems to me there must be a better solution to eliminate everything surrounding the oval. Isn't there any such thing as a non-rectangular picture?

    Al
    Al Millstein Guest

  5. #5

    Default Re: Stupid Question

    No, Al, unfortunately there isn't anything that's non-rectangular. This is the spot for the "all images are made up of pixels" explanation, but you've heard that one before, I think! If you truly need that space around your oval to be transparent, the gif becomes your only alternative - at least using Elements. I can't speak for all other applications out there, though. It's possible another program could get you what you want. Elements is the only one I'm familiar with, and Elements deals in squares and rectangles.
    Beth Haney Guest

  6. #6

    Default Re: Stupid Question

    Al, yes go ahead and try to get that rectangle around your oval as close as possible. You can get as close as a one pixel border on edges and then you just have a little in the corners to deal with. Just use the eyedropper tool to get the sample of the color code in your wepages background to match it up. OR, use the GIF setting: GIF 128 dithered, selective,diffusion, raise dither on slider bar to 100%. This might work for your image depending on how much color/detail it has.
    Jodi Frye Guest

  7. #7

    Default Re: Stupid Question

    You can get a ZERO pixel border on the edges if you File->Crop while the
    oval is selected... presuming you have Feather set to 0.


    Byron Gale Guest

  8. #8

    Default Re: Stupid Question

    Yes, understandably but we were trying to get it to save as a Jpeg with minimal border for webpage use. Jpeg does not support transparency so we needed a fragment of a square behind the oval.
    Jodi Frye Guest

  9. #9

    Default Stupid Question

    Hi Perl Beginners,

    Let's say I have a hash of hashes. And I want to use it over and over
    again, so I need to reinitialize it often. I suppose I could go
    through each key in the hash of hashes, and go through each key in the
    little hashes and use delete on each of them. But isn't there some
    elegant way? Does Perl have a nuke() operator?


    - Jason

    One day there was an earthquake that shook the entire Zen temple. Parts
    of it even collapsed. Many of the monks were terrified. When the
    earthquake stopped the teacher said, "Now you have had the opportunity
    to see how a Zen man behaves in a crisis situation. You may have
    noticed that I did not panic. I was quite aware of what was happening
    and what to do. I led you all to the kitchen, the strongest part of the
    temple. It was a good decision, because you see we have all survived
    without any injuries. However, despite my self-control and composure, I
    did feel a little bit tense - which you may have deduced from the fact
    that I drank a large glass of water, something I never do under
    ordinary cirstances."
    One of the monks smiled, but didn't say anything.
    "What are you laughing at?" asked the teacher.
    "That wasn't water," the monk replied, "it was a large glass of soy
    sauce."

    Jason Dusek Guest

  10. #10

    Default Re: Stupid Question

    Jason Dusek wrote:
    >
    > Hi Perl Beginners,
    Hello,
    > Let's say I have a hash of hashes. And I want to use it over and over
    > again, so I need to reinitialize it often. I suppose I could go
    > through each key in the hash of hashes, and go through each key in the
    > little hashes and use delete on each of them. But isn't there some
    > elegant way? Does Perl have a nuke() operator?
    If you want to clear out the hash completely then:

    %hash = ();

    Will remove all the keys and values from the hash. This will also work
    with a hash of hashes.

    Or if you need to reinitialize it you can just assign the key/value
    pairs to the hash:

    %hash = ( newkey1 => 'newval1', newkey2 => 'newval2' );

    Which will assign the new list, replacing anything that was in there
    before.



    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn Guest

  11. #11

    Default hash of hashes problem - Re: Stupid Question


    On Nov 28, 2003, at 6:26 PM, Jason Dusek wrote:
    > Let's say I have a hash of hashes. And I want to use it over
    > and over again, so I need to reinitialize it often.
    There are two issues here,

    a. how did you initialize it to begin with
    and why not simple re-use that solution

    b. have you looked at perldoc -f delete

    assuming that you really DO need to reinitialize it 'often'
    in the first place.

    > I suppose I could go through each key in the hash of hashes,
    > and go through each key in the little hashes and use delete
    > on each of them. But isn't there some elegant way?
    > Does Perl have a nuke() operator?
    The other idea would be to look at the 'scope' of your
    hoh - you might also want to review say:

    <[url]http://www.rocketaware.com/perl/perldsc/[/url]
    HASHES_OF_HASHES.htm#HASHES_OF_HASHES>

    which has some nice ideas - depending upon the
    depth of your hoh that is...



    ciao
    drieux

    ---

    Drieux Guest

  12. #12

    Default Re: Stupid Question

    Hi Everyone,

    On Friday, November 28, 2003, at 08:51 PM, drieux wrote:
    > a. how did you initialize it to begin with
    > and why not simple re-use that solution
    The hash consists of filenames, line numbers and strings.

    $HASH{$file}{$line} = line of code from some file.

    So the script goes along scouring the present directory for all
    instances of files of type '*.foo' and when it comes to one, it
    searches every last line of it for the pattern /\bfoo\b/ and if (and
    only if) there is a foo in the file, the it puts the name of the file
    in the hash, and then puts the number of each line containing /\bfoo\b/
    in the hash under the file's name, and then puts the line of code
    containing /\bfoo\b/ under the line number. Then it prints out the
    hash and tells me what directory it was in when it did all this.

    So this is all fine well and good. But let us say that I wish to
    rewrite the script so that it scours many directories in sequence, and
    then tells me what it did in each one. There is only one thing that
    needs to be changed - each time it comes to a new directory, it should
    wipe the hash. Then each directories report will not be contaminated
    by the previous report. If I were to simply use the way I had
    initialized the hash in the first place, I would get a very long report
    for the last directory, most of which would be about files in other
    directories! So I need to nuke the hash each time I go through the
    loop.


    - Jason

    When Banzan was walking through the Union Square greenmarket
    he overheard a conversation between a vendor and his customer.
    "Do you have chocolate mousse?" asked the customer.
    "We have chocolate pudding," replied the vendor.
    At these words Banzan became enlightened.
    -Mike Topp
    Jason Dusek Guest

  13. #13

    Default Re: Stupid Question

    Hi Everyone,

    I guess drieux was write about perldoc -f 'delete' - it completely
    solved my problem. So as an act of penance to the Perl community, I
    will flagellate myself right here on this list!

    for (1..108) {
    print 'wap';
    print 'ouch';
    }

    That'll teach me to write to the list before I check the docs.

    - Jason

    A student, in hopes of understanding the Lambda-nature, came to
    Greenblatt. As they spoke a Multics system hacker walked by. "Is it
    true," asked the student, "that PL-1 has many of the same data types as
    Lisp?" Almost before the student had finished his question, Greenblatt
    shouted, "FOO!", and hit the student with a stick.

    Jason Dusek Guest

  14. #14

    Default Re: Stupid Question


    On Nov 28, 2003, at 8:54 PM, Jason Dusek wrote:
    > Hi Everyone,
    >
    > On Friday, November 28, 2003, at 08:51 PM, drieux wrote:
    >> a. how did you initialize it to begin with
    >> and why not simple re-use that solution
    >
    > The hash consists of filenames, line numbers and strings.
    >
    > $HASH{$file}{$line} = line of code from some file.
    >
    > So the script goes along scouring the present directory for all
    > instances of files of type '*.foo' and when it comes to one, it
    > searches every last line of it for the pattern /\bfoo\b/ and if (and
    > only if) there is a foo in the file, the it puts the name of the file
    > in the hash, and then puts the number of each line containing
    > /\bfoo\b/ in the hash under the file's name, and then puts the line of
    > code containing /\bfoo\b/ under the line number. Then it prints out
    > the hash and tells me what directory it was in when it did all this.
    >
    > So this is all fine well and good. But let us say that I wish to
    > rewrite the script so that it scours many directories in sequence, and
    > then tells me what it did in each one. There is only one thing that
    > needs to be changed - each time it comes to a new directory, it should
    > wipe the hash. Then each directories report will not be contaminated
    > by the previous report. If I were to simply use the way I had
    > initialized the hash in the first place, I would get a very long
    > report for the last directory, most of which would be about files in
    > other directories! So I need to nuke the hash each time I go through
    > the loop.
    maybe I'm not seeing why you want to have a HoH
    in the first place, I mean if all you want is

    $HASH{$file}{$line_number} = $specific_instance

    why not modify your notion of $file from 'name of file'
    to say FQN - fully qualified name.

    shifting from bob.c to foo/bar/bob.c

    eg:

    $HASH{'foo/bar/bob.c'}{'123'} = 'and lo there is foo in this code';

    Remember the other side of the classic unix philosophy,
    you malloc from the top, and you free from the bottom,
    so were you to have some hash of the form

    $hash{$foo}{$bar}{$baz}


    you would want to recurse down the structure to
    throw away the leafs first so that one frees them
    up, so that there are no dangling references.

    I of course am a fan of Hash Refs, lifestyle issue,
    hence think in terms of say:


    my $hash = {
    foo => {
    bar => { bar => { thingie => 'a' }
    },
    bar2 => { thingie => 'aq' , b2 => 'other' }
    },
    bar => {
    baz => { wombat => 'a1', frodo => 'baggins'},
    bazBall => {bobo => 'b2', fep => 'friend'}
    },
    bing => '1',
    bong => ['a', 'b', 'c' ],
    };

    print Dumper($hash);

    free_leaf($hash);
    print Dumper($hash);
    #------------------------
    #
    sub free_leaf
    {
    my ($leaf) = _;

    my $ref = ref($leaf);
    return unless( $ref);

    if ($ref eq 'HASH')
    {
    while( my ($k,$v) = each %$leaf )
    {
    free_leaf($v);
    delete($leaf->{$k});
    }
    } elsif ( $ref eq 'ARRAY' )
    {
    while( my $token = shift $leaf )
    {
    free_leaf($token);
    }
    }
    } # end of free_leaf

    ciao
    drieux

    ---

    Drieux Guest

  15. #15

    Default Re: Stupid Question

    "John W. Krahn" wrote:
    > Jason Dusek wrote:
    > >
    > > Hi Perl Beginners,
    >
    > Hello,
    >
    > > Let's say I have a hash of hashes. And I want to use it over and over
    > > again, so I need to reinitialize it often. I suppose I could go
    > > through each key in the hash of hashes, and go through each key in the
    > > little hashes and use delete on each of them. But isn't there some
    > > elegant way? Does Perl have a nuke() operator?
    >
    > If you want to clear out the hash completely then:
    >
    > %hash = ();
    >
    > Will remove all the keys and values from the hash. This will also work
    > with a hash of hashes.
    >
    > Or if you need to reinitialize it you can just assign the key/value
    > pairs to the hash:
    >
    > %hash = ( newkey1 => 'newval1', newkey2 => 'newval2' );
    >
    > Which will assign the new list, replacing anything that was in there
    > before.
    >
    > John
    Thanks, John,

    That indeed is one of the conveniences that makes one truly appreciate the
    beauty of Perl reference-counting, anonymous data structures, and the use of
    references. Makes cleanups fast and easy.

    Joseph


    R. Joseph Newton Guest

  16. #16

    Default Re: Stupid Question

    Jason Dusek wrote:
    > Hi Everyone,
    >
    > On Friday, November 28, 2003, at 08:51 PM, drieux wrote:
    > > a. how did you initialize it to begin with
    > > and why not simple re-use that solution
    >
    > The hash consists of filenames, line numbers and strings.
    >
    > $HASH{$file}{$line} = line of code from some file.
    >
    > So the script goes along scouring the present directory for all
    > instances of files of type '*.foo' and when it comes to one, it
    > searches every last line of it for the pattern /\bfoo\b/ and if (and
    > only if) there is a foo in the file, the it puts the name of the file
    > in the hash, and then puts the number of each line containing /\bfoo\b/
    > in the hash under the file's name, and then puts the line of code
    > containing /\bfoo\b/ under the line number. Then it prints out the
    > hash and tells me what directory it was in when it did all this.
    >
    > So this is all fine well and good. But let us say that I wish to
    > rewrite the script so that it scours many directories in sequence, and
    > then tells me what it did in each one. There is only one thing that
    > needs to be changed - each time it comes to a new directory, it should
    > wipe the hash. Then each directories report will not be contaminated
    > by the previous report. If I were to simply use the way I had
    > initialized the hash in the first place, I would get a very long report
    > for the last directory, most of which would be about files in other
    > directories! So I need to nuke the hash each time I go through the
    > loop.
    >
    > - Jason
    Hi Jason,

    What you have here is a scoping issue. The hash for the current directory
    should be declared inside the recursive function that does your scouring
    work. There is no issue then of cleaing up messes from unrelated, even if
    parallel, parts of your program. If you are designing your code properly,
    this issue simply doesn't exist. A variable scoped iside a function dies
    when that function exits. Even if the function calls itself, the variable
    within each call is discrete.

    Within the function below, the $children array is much less complex than
    your find results hash, but the principle applies equally. There is a
    multidimensional hash or two involved in this function also, but these are
    parameters intended to work from a shared structure, so they don't speak to
    the problem.


    sub load_threaded_messages_to_tree {
    my ($threads, $paths, $message_list,
    $basepath, $for_path, $depth) = _;

    my $children = [sort {$a <=> $b} keys %$threads];
    foreach my $child ($children) {
    my $path = $basepath ? $basepath . ".$child" : $child;
    my $details = get_message_info($child);
    add_threaded_message_to_tree($path, $details,
    $message_list, $child, $for_path);
    load_threaded_messages_to_tree($threads->{$child},
    $paths, $message_list, $path, $for_path, $depth + 1);
    }
    return if not $basepath;
    if ($children > 0) {
    $message_list->setmode($basepath, 'close');
    $message_list->close($basepath);
    } else {
    $message_list->setmode($basepath, 'none');
    }
    }

    What you should note here is that $children exists each time this function
    calls itself. Each time it is a new reference to an independent anonymous
    array. When each call returns the variable inside the called function
    disappears, and its memory is freed. As long as no reference to that array
    is exported from the function, the garbage collection takes care of
    itself. This aint C, with its tricky "Oops, I forgot to free() my
    malloc()" bugs. Do be careful when exporting references, though. You can
    aculate wasted memory bykeeping references to unused data structures in
    scope.

    Joseph

    R. Joseph Newton Guest

  17. #17

    Default Re: Stupid Question

    Joseph wrote:
    >
    > "John W. Krahn" wrote:
    >
    > > Jason Dusek wrote:
    > > >
    > > > Hi Perl Beginners,
    > >
    > > Hello,
    > >
    > > > Let's say I have a hash of hashes. And I want to use it over and over
    > > > again, so I need to reinitialize it often. I suppose I could go
    > > > through each key in the hash of hashes, and go through each key in the
    > > > little hashes and use delete on each of them. But isn't there some
    > > > elegant way? Does Perl have a nuke() operator?
    > >
    > > If you want to clear out the hash completely then:
    > >
    > > %hash = ();
    > >
    > > Will remove all the keys and values from the hash. This will also work
    > > with a hash of hashes.
    > >
    > > Or if you need to reinitialize it you can just assign the key/value
    > > pairs to the hash:
    > >
    > > %hash = ( newkey1 => 'newval1', newkey2 => 'newval2' );
    > >
    > > Which will assign the new list, replacing anything that was in there
    > > before.
    > >
    > > John
    >
    > Thanks, John,
    >
    > That indeed is one of the conveniences that makes one truly appreciate the
    > beauty of Perl reference-counting, anonymous data structures, and the use of
    > references. Makes cleanups fast and easy.
    Hi Joseph.

    I agree with your point, but there's no reference counting involved here
    (unless the hash values were themselves references).

    Rob


    Rob Dixon Guest

  18. #18

    Default Re: Stupid Question

    Rob Dixon wrote:
    > Joseph wrote:
    > >
    > > >
    > > > %hash = ();
    >
    > Hi Joseph.
    >
    > I agree with your point, but there's no reference counting involved here
    > (unless the hash values were themselves references).
    >
    > Rob
    I'll be darned, you're right. I just noticed, as I was about to argue the
    contrary, that hash was declared statically with %. I so rarely do this,
    especially if I'm intending to build a mutlidimensional structure, that I assumed
    the base variable was a reference to an anonymous hash. Even so, I think that the
    internal hashes are kept alive by the refeences to them within the structure., and
    therefore are freed when the hash elements referring to them no longer exist. If
    I'm missing something here, let me know.

    Clearly if his structure is working as a multidimesional one, then it has to be
    held together through references, because we know the flattening that takes place
    when any whole structure inserted into an array or hash.

    Joseph


    R. Joseph Newton Guest

  19. #19

    Default Re: Stupid Question


    On Nov 29, 2003, at 12:29 PM, Rob Dixon wrote:
    [..]
    > I agree with your point, but there's no reference counting involved
    > here
    > (unless the hash values were themselves references).
    >
    > Rob
    I think that is a part of the issue that
    folks need to also be thinking about when
    they are putting together HoH and the like.

    As a general rule

    simple things are simple

    the problem of course is that Perl can
    let one get complex Real Quickly. As
    most folks notice, we keep seeing the
    general

    how do I create dynamic variables
    from this list of things I read from
    some file, so that I can do....

    and we have to remind them, that while it
    is possible to smack in the

    no strict 'refs';

    to work around the 'kvetching' there are
    good reasons to avoid bad ju-ju that comes
    down that lane.

    The same is unfortunately involved in the
    whole 'reference count' mechanism that perl
    uses for memory management. So while hashes,
    and hash references are core to perl's slickness,
    they are not 'free' and folks need to do some
    basic design work about what type of data structures
    are they using, what are their scoping issues, and
    are they 'hacking' themselves into a corner either
    by trying to be TOO Cleaver, or Too 'able to extend'
    and... all the same vices that plague 'real coders'
    programming in 'RealCodingLanguages' on RealOS's...

    ciao
    drieux

    ---

    Drieux Guest

  20. #20

    Default Re: Stupid Question

    Rob Dixon wrote:
    >
    > Joseph wrote:
    > >
    > > "John W. Krahn" wrote:
    > > >
    > > > If you want to clear out the hash completely then:
    > > >
    > > > %hash = ();
    > > >
    > > > Will remove all the keys and values from the hash. This will also work
    > > > with a hash of hashes.
    > > >
    > > > Or if you need to reinitialize it you can just assign the key/value
    > > > pairs to the hash:
    > > >
    > > > %hash = ( newkey1 => 'newval1', newkey2 => 'newval2' );
    > > >
    > > > Which will assign the new list, replacing anything that was in there
    > > > before.
    > >
    > > That indeed is one of the conveniences that makes one truly appreciate the
    > > beauty of Perl reference-counting, anonymous data structures, and the use of
    > > references. Makes cleanups fast and easy.
    >
    > I agree with your point, but there's no reference counting involved here
    > (unless the hash values were themselves references).
    AFAIK all variables have a reference count.

    $ perl -e'
    use Devel::Peek;
    $c = 1; Dump $c;
    our $d = 2; Dump $d;
    my $e = 3; Dump $e;
    f = 4; Dump f;
    %g = ( 5, 6 ); Dump %g;
    '
    SV = IV(0x8100f30) at 0x810a968
    REFCNT = 1
    FLAGS = (IOK,pIOK,IsUV)
    UV = 1
    SV = IV(0x8100f34) at 0x810a8b4
    REFCNT = 1
    FLAGS = (IOK,pIOK,IsUV)
    UV = 2
    SV = IV(0x8100f38) at 0x810da98
    REFCNT = 1
    FLAGS = (PADBUSY,PADMY,IOK,pIOK,IsUV)
    UV = 3
    SV = IV(0x8100f3c) at 0x80f47a0
    REFCNT = 1
    FLAGS = (IOK,pIOK,IsUV)
    UV = 4
    SV = PV(0x80f4a6c) at 0x80f46b0
    REFCNT = 1
    FLAGS = (TEMP,POK,pPOK)
    PV = 0x8104030 "5"\0
    CUR = 1
    LEN = 2




    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn Guest

Page 1 of 2 12 LastLast

Similar Threads

  1. Stupid question.
    By duit in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: April 4th, 07:04 PM
  2. Stupid Question??
    By Tina in forum ASP.NET Building Controls
    Replies: 1
    Last Post: January 14th, 02:30 AM
  3. OK. I'm asking a stupid question
    By JeffreyWells webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 3
    Last Post: October 20th, 08:10 PM
  4. a stupid question
    By Joe in forum PHP Development
    Replies: 2
    Last Post: July 24th, 10:37 AM
  5. Stupid Question, but need heLp
    By R1CH1E R1CH webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 2
    Last Post: July 19th, 01:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139