Sponsored Content
Top Forums Shell Programming and Scripting Truncate the content within alt attribute to first 250 characters. Post 302285103 by parshant_bvcoe on Saturday 7th of February 2009 07:59:13 AM
Old 02-07-2009
Truncate the content within alt attribute to first 250 characters.

I have a xml file which contains image tag as follows:

<image><img src="wstc_0007_0007_0_img0001.jpg" width="351" height="450" alt="This is the cover page. Brazil &#x2022; Japan &#x2022; Korea &#x2022; Mexico &#x2022; Singapore &#x2022; Spain" type="photograph" orient="portrait"/></image>

Now, i want to write a script that will count whether the number of characters within alt attribute are greater than 250 and if it is; the data within alt attribute should be truncated to contain only first 250 characters.

It would be really nice if anybody could provide me the way to do so.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

alt boot

ok guys, I have been given a big project, I need to implement alt boot on over 40+ servers, mainly solaris 8 and AIX 4.3, AIX 5.1. A couple of questions 1)can someone describe alt boot, my take is that if the primary disk fails(disk with root filesystems), this altboot disk takes over 2)can... (4 Replies)
Discussion started by: csaunders
4 Replies

2. UNIX for Dummies Questions & Answers

Truncate last <n> characters from a file

I am trying to concatenate 2 files, but before concatenation, I would like to strip off the final character from the first file. The final character is a form feed (ascii 012 / hex 0C) and there will be an unknown number of these characters in the file. It is only the very last one which I want... (1 Reply)
Discussion started by: Gwailo88
1 Replies

3. UNIX for Dummies Questions & Answers

Alt - Characters

in Win, one can use the Alt + 3-digit numeric code combination to spawn any ASCII character. Linux, OTOH has Ctrl-Shift-U + alphanumeric code combination to spawn any UNICODE character. bottom line: I'd like to be able to do what Win can do, please. I was told it was possible, but made... (5 Replies)
Discussion started by: ialoq
5 Replies

4. Shell Programming and Scripting

Truncate file name to 40 characters

Hello all. I would like to make a script (or two shell scripts) that will do the following. I need the maximum file name and directory name to be 38 characters long. As well, if shortening the file name ends up making all of the files in that directory have the same name, then I would like... (9 Replies)
Discussion started by: marcozd
9 Replies

5. Shell Programming and Scripting

how to delete special characters from the file content

Hello Team, Any one suggest how to delte the below special character from a file which is having one column 10 rows of same below content. ---------------------------------------- Kosten|bersicht gemd_ ' =Welche Kosten kvnnen... (2 Replies)
Discussion started by: kanakaraju
2 Replies

6. Shell Programming and Scripting

Truncate all characters and numbers in string - using perl

hi, I have an data from file where it has 20110904 234516 <<hdd-10#console|0c.57,passed,5,28,READ,0,20822392,8,5,4,0,40,0,-1,0,29909,25000,835,3.3,0,0,0,0,implied,0,0,2011/9/5-2:3:17,2011/9/5-2:3:47,X292_0F15,TAP ,NQ09,J40LTG\r\r\n I want to remove characters till #console| i.e want... (1 Reply)
Discussion started by: asak
1 Replies

7. Shell Programming and Scripting

Matching a pattern 250 characters up and down stream

hii all i have a file a which contains some thing like this strand smthg position + yyx 3020 - yyw 10,000 now i have another file (file2) which contains the data starting from 1 to n positions i want to refer first file if + ... (4 Replies)
Discussion started by: anurupa777
4 Replies

8. AIX

alt clone

I have two identical systems p740 with 2 lpars in each server. I dont want to install os from scratch on each lpar neither I want to use nim nor mksysb. Will it work perfectly if I install a fresh OS on 1 lpar and do alt disk clone for other lpras. My each lpar is having 2 physical disks. Now if... (2 Replies)
Discussion started by: vjm
2 Replies

9. Shell Programming and Scripting

How to truncate a string to x number characters?

Hello: I have a large file which contains lines like the following: 1/t123ab, &Xx:1:1234:12345:123456@ABCDEFG... at -$100.00% /t is a tab, spaces are as indicated the string "&Xx:1:1234:12345:123456$ABCDEFG..." has a slightly variable number of numbers and letters, but it always starts... (9 Replies)
Discussion started by: Tectona
9 Replies
Template::Plugin::Image(3)				User Contributed Perl Documentation				Template::Plugin::Image(3)

NAME
Template::Plugin::Image - Plugin access to image sizes SYNOPSIS
[% USE Image(filename) %] [% Image.width %] [% Image.height %] [% Image.size.join(', ') %] [% Image.attr %] [% Image.tag %] DESCRIPTION
This plugin provides an interface to the Image::Info or Image::Size modules for determining the size of image files. You can specify the plugin name as either '"Image"' or '"image"'. The plugin object created will then have the same name. The file name of the image should be specified as a positional or named argument. [% # all these are valid, take your pick %] [% USE Image('foo.gif') %] [% USE image('bar.gif') %] [% USE Image 'ping.gif' %] [% USE image(name='baz.gif') %] [% USE Image name='pong.gif' %] A "root" parameter can be used to specify the location of the image file: [% USE Image(root='/path/to/root', name='images/home.png') %] # image path: /path/to/root/images/home.png # img src: images/home.png In cases where the image path and image url do not match up, specify the file name directly: [% USE Image(file='/path/to/home.png', name='/images/home.png') %] The "alt" parameter can be used to specify an alternate name for the image, for use in constructing an XHTML element (see the "tag()" method below). [% USE Image('home.png', alt="Home") %] You can also provide an alternate name for an "Image" plugin object. [% USE img1 = image 'foo.gif' %] [% USE img2 = image 'bar.gif' %] The "name" method returns the image file name. [% img1.name %] # foo.gif The "width" and "height" methods return the width and height of the image, respectively. The "size" method returns a reference to a 2 element list containing the width and height. [% USE image 'foo.gif' %] width: [% image.width %] height: [% image.height %] size: [% image.size.join(', ') %] The "modtime" method returns the modification time of the file in question, suitable for use with the Date plugin, for example: [% USE image 'foo.gif' %] [% USE date %] [% date.format(image.modtime, "%B, %e %Y") %] The "attr" method returns the height and width as HTML/XML attributes. [% USE image 'foo.gif' %] [% image.attr %] Typical output: width="60" height="20" The "tag" method returns a complete XHTML tag referencing the image. [% USE image 'foo.gif' %] [% image.tag %] Typical output: <img src="foo.gif" width="60" height="20" alt="" /> You can provide any additional attributes that should be added to the XHTML tag. [% USE image 'foo.gif' %] [% image.tag(class="logo" alt="Logo") %] Typical output: <img src="foo.gif" width="60" height="20" alt="Logo" class="logo" /> Note that the "alt" attribute is mandatory in a strict XHTML "img" element (even if it's empty) so it is always added even if you don't explicitly provide a value for it. You can do so as an argument to the "tag" method, as shown in the previous example, or as an argument [% USE image('foo.gif', alt='Logo') %] CATCHING ERRORS
If the image file cannot be found then the above methods will throw an "Image" error. You can enclose calls to these methods in a "TRY...CATCH" block to catch any potential errors. [% TRY; image.width; CATCH; error; # print error END %] USING Image::Info At run time, the plugin tries to load Image::Info in preference to Image::Size. If Image::Info is found, then some additional methods are available, in addition to "size", "width", "height", "attr", and "tag". These additional methods are named after the elements that Image::Info retrieves from the image itself. The types of methods available depend on the type of image (see Image::Info for more details). These additional methods will always include the following: file_media_type This is the MIME type that is appropriate for the given file format. The corresponding value is a string like: ""image/png"" or ""image/jpeg"". file_ext The is the suggested file name extention for a file of the given file format. The value is a 3 letter, lowercase string like ""png"", ""jpg"". color_type The value is a short string describing what kind of values the pixels encode. The value can be one of the following: Gray GrayA RGB RGBA CMYK YCbCr CIELab These names can also be prefixed by ""Indexed-"" if the image is composed of indexes into a palette. Of these, only ""Indexed-RGB"" is likely to occur. (It is similar to the TIFF field PhotometricInterpretation, but this name was found to be too long, so we used the PNG inpired term instead.) resolution The value of this field normally gives the physical size of the image on screen or paper. When the unit specifier is missing then this field denotes the squareness of pixels in the image. The syntax of this field is: <res> <unit> <xres> "/" <yres> <unit> <xres> "/" <yres> The "<res>", "<xres>" and "<yres>" fields are numbers. The "<unit>" is a string like "dpi", "dpm" or "dpcm" (denoting "dots per inch/cm/meter). SamplesPerPixel This says how many channels there are in the image. For some image formats this number might be higher than the number implied from the "color_type". BitsPerSample This says how many bits are used to encode each of samples. The value is a reference to an array containing numbers. The number of elements in the array should be the same as "SamplesPerPixel". Comment Textual comments found in the file. The value is a reference to an array if there are multiple comments found. Interlace If the image is interlaced, then this returns the interlace type. Compression This returns the name of the compression algorithm is used. Gamma A number indicating the gamma curve of the image (e.g. 2.2) AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/> COPYRIGHT
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin, Image::Info perl v5.12.1 2008-11-13 Template::Plugin::Image(3)
All times are GMT -4. The time now is 03:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy