Perl/CGI : format several images - perl

Need a bit more help please...
I need to display 24 times :
or
or
(depending on speed/duplex on the port)
But those images have to be displayed in the switch's image :
How to do to get all images well formated ??
To know which color to choose, I wrote a perl script using Net::SNMP to get infos about speed, duplex...
Thanks guys.
Bye

Hm. Actually, I'd be more tempted to take the images and use CSS styles to color them.
For example, if you took one of those and turned the colored areas transparent, you could place them using CSS, and change the background color, either with generated Perl or with JavaScript on the fly.
It gets a little complex, admittedly; you'll have to create 26 styles (one for each switch), placing them appropriately. You'll need two images (right-side up and upside-down). You'd also have
.yellow { background-color: yellow; }
and so on. But then it's just a matter of adding the appropriate class to the appropriate div; no need to load six different image variants (just two), and you gain the ability to adjust the colors to be anything you want with just a change to the CSS, and do so dynamically if you like.
Does that make any sense?

PerlMagick

Related

cannot find css element in protractor

How do I locate the element with the following html, I have 4 Start buttons each in different color. I tried using css by class and is not working. There are no unique ids as well. Pls help
Start
As Ben Mohorc points out, you really need to give us a bit more to go on. But if you are saying there are multiple start buttons, but only one of each color, it ought to look like this. For now I assume all they say is "Start". If that is only part of what they say, use partial buttontext.If it is background color that differs, you may need to adapt that, too.
var coloredButton = element.all(by.buttonText('Start')).filter(function(elem) {
return elem.getCssValue('color').then(function(color) {
return (color == '#00ff00')//fill in the desired color here, in this format
})
});
Then do your stuff on coloredButton.first(), which will be the only one, according to what you are saying.
For more on the format to expect from the color, see http://www.protractortest.org/#/api?view=webdriver.WebElement.prototype.getCssValue

Change small_image size Magento

I need to change the small image size on Magento community.
Here´s why, it does not fit the global product window.
link here
I tried at \app\design\frontend\default\magik_pinstyle\template\catalog\product\list.phtml
and flushed the image cache but I does not work.
I can see it`s a 265px image but when I search for a resize(265) I dont find anything.
This would actually be located in app/design/frontend/default/magik_pinstyle/template/catalog/product/view/media.phtml. Copy the file over from app/design/frontend/base/default/template/catalog/product/view/media.phtml if you don't have it on your template. On line 68 (in the base media.phtml) you'll find this line:
$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" itemprop="image" />';
Your photos don't fit the frame because your .product-view .product-img-box .product-image CSS is set to 320x300px (width/height). If you want your pictures to fit, you need to make sure the resize is set to the same size of the frame, and you should probably square off your frame.
If you want the larger frame, change your image CSS to 320x320px or 300x300px and change the above line to resize(320) or resize(300), respectively.
If you want to keep the 265x265px image size, change your image CSS to 265x265px and leave it as is.
Edit
It is still using a file in 265x265px resize cache.
You should deliberately clear out everything in your /media/catalog/product/cache folder, first the media.phtml checks to see if a resize already exists and falls back to that. If one isn't found, then it runs the resize.
You are editing the file found in app/design/frontend/default/magik_pinstyle/template/catalog/product/view/media.phtml, correct? If altering the existing resize function doesn't work after completely emptying the cache you can add the ->resize(300) function to line 15:
$this->helper('catalog/image')->init($_product, 'image')->resize(300)
Lastly, if you have a custom lightbox or theme section in your settings, check for anything you may have missed to alternately set dimensions.
Make sure to refresh your cache, you should clear your image cache too.
I know that this is an old post but but I want to add something that seems to be left out off most of these responses, you must enlarge the container that the image is contained in otherwise the image will not be enlarged.
I followed the first part of Jason's answer above by going into
app/design/frontend/default/magik_pinstyle/template/catalog/
/view/media.phtml. Copy the file over from app/design/frontend
/base/default/template/catalog/product/view/media.phtm
and changing line 32 and 33 to
$bigImageX = 608; from $bigImageX = 308;
$bigImageY = 608; from $bigImageY = 308;
and nothing happened after flushing of the cache both magento nor browswer.
I then went into dev tools and enlarged the width of
<div class="produt-img-box">
which increased the size of the image to my desired size.
Just to be clear, I also had to shrink the size of the
<div class="product-shop"> to totally accomplish my goal of resizing the image.

Font shadows using Raphaël—JavaScript Library

I would like to put a shadow around any given text, or make the text more anti-aliased looking.
For example lets say I'm running a simple text such as:
var titleName = R.text(x+200, y-75, "Lorem Ipsoup de jour")
.attr({font: '75px Helvetica, Arial', opacity: 1, fill: "#dfe6ec"})
The text is somewhat chunky looking at that size, and doesn't blend well against a background. Is there a way I can create a drop-shadow effect (with alpha channel, ideally)?
In SVG a text shadow effect isn't as simple as with CSS3, but it's reasonably straightforward using a filter. You can't use that example as is in Raphaël because it has no support for groups, but you might be able to create the filter definition in an external file and then apply it with:
.attr({filter: "url(filters.svg#dropShadow)"});
--edit
I've had a chance to give it a try and it doesn't work because filter isn't recognised by attr, however it does work (in Firefox) if you grab the node and use a regular DOM setAttribute method.
var t = paper.text(100, 100, "Raphaël\nkicks\nbutt!");
t.node.setAttribute("filter", "url('filters.svg#dropShadow')");
Chrome doesn't apply the drop shadow, and Opera blurs the entire element. It almost certainly won't work in IE because that'll be VML. Example here.
I know this is an old question, but to help anyone else searching for this you can try Element.glow([glow]) to get a shadow effect. http://raphaeljs.com/reference.html#Element.glow

How can I set a custom size for the RichTextArea.Formatter.setFontSize() in GWT?

Using the RichTextArea in GWT, It looks like I can only change the font size to one of the values: LARGE, MEDIUM, SMALL, etc (RichTextArea.FontSize), but I want to be able to setFontSize of the RichTextArea.Formatter to a specific size in pt or in px.
How can I achieve that?
I've been digging a bit on this, and it would seem that it is unfortunately not possible, because browsers are limited in their handling of font sizes in the rich text editors. In particular, Firefox generates the (deprecated) <font size="x"></font> element when the font size is changed, and the value of x can be only in the 1-7 range.
If you have a look at the setFontSize method in RichTextAreaImplStandard (GWT source code), you'll see that it ends up calling the execCommand javascript function, which in the case of FontSize only accepts values in 1-7:
http://msdn.microsoft.com/en-us/library/ms536991%28VS.85%29.aspx
You can actually achieve that using string manipulation of the HTML code.
So if you are not using the background color property of the RichTextArea then what you have to do is to replace the "background-color=RED" to "font-size=12px". And then set it back to the RichTextArea object as setHTML().
This works fine as I've implemented this functionality in one of our production application..
Thanks,
Pratik.

How to slice text or html string into pages with iPhone SDK?

How to slice some text (html) string into number of pages to be possible read text as a book?
Thanks for suggestions.
Assuming you are happy recognising only a subset of HTML markup without CSS (here I assume <p/><b/><i/><br/> tags only plus <font size=/> for font size changes (with other attributes ignored), <img> tags for images with all but src,width,height ignored and accurate width and height mandatory with all other tags/attributes ignored):-
TidyLib seems to have an MIT license - http://tidy.sourceforge.net/#source
SAX parse the XHTML output of TidyLib using NSXmlParser into a custom object model (unless you are exclusively using later versions of iPhone OS with public builtin DOM parser API in which case just use a DOM object model).
Set up a state machine with a caret position at top left of page and initial font size and formatting, page number of 1, maximum height of glyphs/images in current line of zero, and empty list of page boundaries.
For each run of text or image in object model, apply pre-ceding font size/format modifications, measure text using iPhone text measurement calls, reducing text length (trim to nearest space or hyphen) until it fits on current line, and resetting caret to line beginning and continuing for line wraps, and apply following font size and formatting changes. Over-count the width and height of text by some factor in cases where this is found to be required to prevent page overflow in the actual page rendering engine (UIWebView; you will have to experiment to see what the factors in the rendering engine are). Record page boundary in list.
Convert objects between page boundaries to simplified XHTML for each page. You may wish to add some CSS at this point for example to format link colours. You will need to convert local references to anchors on another page to load the correct other page. Perhaps add page footer/header with page numbers (subtract size of these from page height in earlier steps).
Save XHTML as set of files.
In essence this will work as long as the source HTML is specially prepared to use a subset of HTML for your app. Any old HTML will not do, though it might perhaps not be completely useless to give a rough idea for previews in some instances for some files.
The description above assumes you throw away formatting like ALIGN= and tables. It really is a very basic approach and will not reproduce complex pages as originally designed! It might well not suit you!
Perhaps the files should be pre-processed before reaching the iPhones in the field but if the iPhone OS / WebView line-wrapping/test positioning behaviour changes, the best position for page breaks may change. So you may need to cut your pages smaller than you think they need to be to allow for some unexpected growth when the rendering engine changes. Hmm. Perhaps not an easy task!
I haven't even tried to analyse HTML tables... HTML is of course, in its non-restricted full glory enormously probably unmanageably complex.