I have a problem. I have svg code. I need to convert it to png. I get an error when converting it. On the product server it works fine (no docker there). Now I'm trying to do it all through docker.
Error
must specify image size `/tmp/magick-pvKVqqZOgZLEImdlmik0Tl8aUFPkNFlM' # error/mvg.c/ReadMVGImage/186
Code
$imagick = new Imagick();
$imagick->readImageBlob($svg);
Dockerfile
FROM composer:2.1 AS composer
FROM php:7.3-fpm as base
RUN apt update && apt install -y --no-install-recommends \
git \
openssh-client \
libzip-dev \
libpq-dev \
unzip \
libpng-dev \
libjpeg-dev \
libwebp-dev \
libmagickwand-dev \
ffmpeg && \
rm -r /var/lib/apt/lists/*
# PHP extensions
RUN pecl install pcov
COPY php.ini /usr/local/etc/php/conf.d/40-custom.ini
RUN docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd && \
docker-php-ext-configure opcache --enable-opcache && \
docker-php-ext-install zip pdo_pgsql pdo_mysql mysqli bcmath opcache gd exif && \
docker-php-ext-enable zip pdo_mysql mysqli opcache gd pdo_pgsql pcov
WORKDIR /var/www/laravel9
ENV PATH="$PATH:/src/vendor/bin"
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY composer.* ./
RUN pecl install imagick && docker-php-ext-enable imagick
FROM base as prod
COPY . ./
RUN chgrp -R www-data storage bootstrap/cache && chmod -R ug+rwx storage bootstrap/cache \
&& composer dump-autoload --optimize
FROM base as dev
RUN composer install --no-scripts --no-autoloader --no-interaction --dev
COPY . ./
RUN chgrp -R www-data storage bootstrap/cache && chmod -R ug+rwx storage bootstrap/cache \
&& composer dump-autoload --optimize
svg
<svg xmlns="http://www.w3.org/2000/svg" border="0" data-ac-wrapper-id="1" width="100%" height="100%" class="anychart-ui-support" ac-id="ac_stage_0" style="display: block;"><defs></defs><g data-ac-wrapper-id="2" id="ac_layer_1"><g data-ac-wrapper-id="39" id="ac_layer_12"><path data-ac-wrapper-id="42" id="ac_path_15" fill="none" stroke="black" d="M 45.844 20 L 100.578 20 A 3 3 0 0 1 103.578 23 L 103.578 65 A 5 5 0 0 1 98.578 70 L 47.844 70 A 5 5 0 0 1 42.844 65 L 42.844 23 A 3 3 0 0 1 45.844 20 Z"></path><text data-ac-wrapper-id="43" font-family="Arial, Helvetica, sans-serif" font-size="14px" fill="#000" direction="ltr" text-anchor="start" x="52.58990625" y="50.75" id="ac_text_16" style="opacity: 1;"><tspan x="52.58990625" dy="0">П20лв</tspan></text><path data-ac-wrapper-id="44" id="ac_path_17" fill="none" stroke="black" d="M 42.844 56 L 103.578 56"></path><text data-ac-wrapper-id="45" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="#000" direction="ltr" text-anchor="start" x="69.539625" y="66.75" id="ac_text_18" style="opacity: 1; cursor: pointer;"><tspan x="69.539625" dy="0">X</tspan></text><text data-ac-wrapper-id="46" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="#000" direction="ltr" text-anchor="start" x="90.24165625" y="66.75" id="ac_text_19" style="opacity: 1; cursor: pointer;"><tspan x="90.24165625" dy="0">></tspan></text><path data-ac-wrapper-id="47" id="ac_path_1a" fill="none" stroke="black" d="M 52.514 90 L 73.211 70"></path><path data-ac-wrapper-id="50" id="ac_path_1d" fill="none" stroke="black" d="M 149.422 20 L 204.156 20 A 3 3 0 0 1 207.156 23 L 207.156 65 A 5 5 0 0 1 202.156 70 L 151.422 70 A 5 5 0 0 1 146.422 65 L 146.422 23 A 3 3 0 0 1 149.422 20 Z"></path><text data-ac-wrapper-id="51" font-family="Arial, Helvetica, sans-serif" font-size="14px" fill="#000" direction="ltr" text-anchor="start" x="151.62103125" y="50.75" id="ac_text_1e" style="opacity: 1;"><tspan x="151.62103125" dy="0">ДКР160</tspan></text><path data-ac-wrapper-id="52" id="ac_path_1f" fill="none" stroke="black" d="M 146.422 56 L 207.156 56"></path><text data-ac-wrapper-id="53" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="#000" direction="ltr" text-anchor="start" x="153.32965625" y="66.75" id="ac_text_1g" style="opacity: 1; cursor: pointer;"><tspan x="153.32965625" dy="0"><</tspan></text><text data-ac-wrapper-id="54" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="#000" direction="ltr" text-anchor="start" x="173.117625" y="66.75" id="ac_text_1h" style="opacity: 1; cursor: pointer;"><tspan x="173.117625" dy="0">X</tspan></text><path data-ac-wrapper-id="55" id="ac_path_1i" fill="none" stroke="black" d="M 142.514 90 L 176.789 70"></path><text data-ac-wrapper-id="57" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="red" direction="ltr" text-anchor="start" x="56.38678125" y="31.75" id="ac_text_1k" style="opacity: 1;"><tspan x="56.38678125" dy="0">14 690</tspan></text><text data-ac-wrapper-id="58" font-family="Arial, Helvetica, sans-serif" font-size="11px" font-weight="bold" fill="red" direction="ltr" text-anchor="start" x="156.9061875" y="31.75" id="ac_text_1l" style="opacity: 1;"><tspan x="156.9061875" dy="0">139 610</tspan></text></g><g data-ac-wrapper-id="40" id="ac_layer_13" transform="matrix(1,0,0,1,42.514,90)"><path data-ac-wrapper-id="41" id="ac_path_14" fill="none" stroke="black" d="M 8 0 L 12 0 A 8 8 0 0 1 20 8 L 20 102 A 8 8 0 0 1 12 110 L 8 110 A 8 8 0 0 1 -8.881784197001252e-16 102 L 0 8 A 8 8 0 0 1 8 1.7763568394002505e-15 Z"></path><path data-ac-wrapper-id="48" id="ac_path_1b" fill="none" stroke="black" d="M 28 0 L 172 0 A 8 8 0 0 1 180 8 L 180 27 A 8 8 0 0 1 172 35 L 28 35 A 8 8 0 0 1 20 27 L 20 8 A 8 8 0 0 1 28 1.7763568394002505e-15 Z"></path><path data-ac-wrapper-id="49" id="ac_path_1c" fill="none" stroke="black" d="M 28 35 L 172 35 A 8 8 0 0 1 180 43 L 180 107 A 8 8 0 0 1 172 115 L 28 115 A 8 8 0 0 1 20 107 L 20 43 A 8 8 0 0 1 28 35 Z"></path></g><g data-ac-wrapper-id="56" id="ac_layer_1j"></g></g></svg>
Related
I have a stranger document that I don't know which extension it is, and I need to convert it into a PDF, so the idea is to get that content dynamically, then we save it in server as a PDF
My try :
$responce = $this->getDocumentContent();//this function returns me the $responce content bellow.
$documentFolder = $this->getDirectory().'/document/'; //var/www/project/document/
$documentFullPath = $this->getDirectory().'/document/file1.pdf';
$this->_io->mkdir($documentFolder, 0775);//create folder var/www/project/document
$document = fopen($documentFullPath, "w+");//create pdf file var/www/project/document/file1.pdf
fwrite($document, $responce);
fclose($document);
Now with this code, I create well the file1.pdf in var/www/project/document/file1.pdf but it is empty !, there is no content, the file1.pdf weight is not 0 but 163.2 Ko but I see anything. I don't know where is the issue.
$responce =
string(163146) "%PDF-1.4
%????
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
/Metadata 63 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 01 0 R 8 0 R ]
/Count 2
/MediaBox [ 0 0 618 003 ]
>>
endobj
3 0 obj
<<
/ModDate (D:20190907120701+02'00')
/CreationDate (D:20130904150701+02'00')
/Title (F:/Data/Composer/0510.IN.PDF)
/Subject (NONE)
/Author (User: Windows XP/ User)
/Creator (PDF/PReS Version: 6.1.1 )
/Producer ([ClibPDF Library 2.02-r1-2] Windows XP)
>>
endobj
5 0 obj
<<
/Type /Page
/Parent 2 0 R
/Resources << /Font << /Fcpdf0 30 0 R >> /XObject << /6p 8 0 R >> /ProcSet 7 0 R >>
/MediaBox [ 0 0 595 842 ]
/CropBox [ 0 0 595 842 ]
/Rotate 0
/Contents 6 0 R
>>
endobj
6 0 obj
<< /Length 246 /Filter [ /FlateDecode ] >>
stream
x??QMk?#?'1?bia=?!?L6I7?V??AB??AQ(???_:?T?"$;<vf??7?I??c?(?(?????F??4?E?<L?ku????xs???w*??
??FGD?AlY?{,???E??-A????u?o?/^^O%|??>???\?T?Y
??iS??5q?t?C2I??q???c>?V?z?8:??C??#???p/?\???0F)k#?1???U?`Sa?????.???PyoY
endstream
endobj
7 0 obj
[
/PDF /Text /ImageC
]
endobj
8 0 obj
<< /Type /XObject /BBox [ 0 0 595 842 ] /Filter /FlateDecode /FormType 1
/Length 17871 /Matrix [ 1 0 0 1 0 0 ] /Resources << /ColorSpace << /CS0 27 0 R /CS1 26 0 R /CS10 27 0 R /CS11 26 0 R /CS12 27 0 R /CS13 26 0 R
/CS14 29 0 R /CS15 28 0 R /CS16 29 0 R /CS17 28 0 R /CS18 29 0 R
/CS19 28 0 R /CS2 27 0 R /CS20 29 0 R /CS21 28 0 R /CS22 29 0 R
/CS23 28 0 R /CS24 29 0 R /CS25 28 0 R /CS26 29 0 R /CS27 28 0 R
/CS28 29 0 R /CS29 28 0 R /CS3 26 0 R /CS30 29 0 R /CS31 28 0 R
/CS32 29 0 R /CS33 28 0 R /CS34 29 0 R /CS35 28 0 R /CS36 29 0 R
/CS37 28 0 R /CS4 27 0 R /CS5 26 0 R /CS6 27 0 R /CS7 26 0 R /CS8 27 0 R
/CS9 26 0 R >>
/ExtGState << /GS6 25 0 R >> /Font << /TT24 21 0 R /TT25 17 0 R /TT26 13 0 R /TT27 9 0 R >>
/ProcSet [ /PDF /Text ] >>
/Subtype /Form >>
stream
x??}i?$????K?l2?#?:gu?F??????r$?im?1k???????E???????;?O???=????????????7?????o????oO??????}???O??uz?????z?O????p=M???4n~??w/??;|????OGw>???>???9???cSn'????b????5????????w??\????????_~????t?w8N??9??~?f}??qxy??????o???????M??????'?Or4|?O????|??y??o???=?=
?y?p??1vx?)??7???on????.??w?????-??K??|y:?w}d??????:???>uv??:?.???y???6?nm{????E0\??????n?????B??ra*??x?t?K^???'??7?i?8???]?p?D}??T??-?lcN???_????Q7h??n??s???n==?
??!?
?#~s??F8??G?0?K??e??ul?3n???g??????6?0?a???$??L?j?W??9~U??{?G?U??9fO?????rL?K[Z??E?!????}T|?yr/?}?+?O???6??um????a??E^?K??P??U:??+?pL??N?Q????^\?{a???[??k?N?t/????K{?Ek_???
???t??U#??\O;??????????5??~???????
K??O??9?????</?(?*7????u?n?xa?4??rbd??^N?^z??]?7?T????r?f????|Y?ij?mC'u3???o?4On?r???Kd+
?.??t?6??(?fa+5?$??5?}??,??ZB?Fe??E5W(??.J7??yk1??u?F\?o:^???hK???vNH?]?K???r?????U??H?d?????
X???[e3 7???????qz?K?7c1>?
??o?y??Q????<?8???G4??????^?u?&??&?r???'?o??LN?_?? l??1an+G9&?m?1~?'?e?<?
!??o?-??????J?r???x??`?/o?-??=????y?,????R?0y?? ??.rz|3?GhmS? U?!t????A?Oi????}?6??ct5?i???|?.?&?\??]???2?n?\?<7? ?>?4??"X1M?j??>H??}???iX??~???^?????q?????)
??;2?????'??bS????d???N?/L???K?\n?=n~&F?????fd;m?4?c????Xf??'9?D?s????`4,Mg?f????F??n?~-?????+#l??1??z?N�????l??$??+J?N6? ???}:j8Q?????$L?|C?&???^ch?70??C(?????&??????8B?L.??A??D0]?5?+?)??d?X?>??0C??|?A?&?Z???H??J?0?(m?Rr?Y???*???3?o???{??c?[???E?5 ????q?k??:V;T4?+T??>*B(???|I??}?T??7?N??�?g?W?'??U?'2v`? 4????O?)??x?*r?,?b^7??/3??y(M?Nnnd??i??????:?,?|??EYtx/]?g?!?sgi-{?i<?"????????`??4?[�??h?s*???L?,#??8???G?-(%???=?o/A?????!?????_"??%????_??y???a?%???G4?r?|?M??#z=?~???&v?J?]?<?tQ?
??n?�j?GHh[???&J??!?p?l?b?_w?\ ?#?dXb??a}?l??????S5"D~?5??w??n?.v?C?^?E??;?]????#????a???Z>Tb?;Et U?<?; pl?k???b+?m??`????Is?$3<??6??K?w??
rz???e??i#?5$;-??q4Z"????(_5??E??L?ayv
y?s?M?????R?p?T8?-B?o??i?_?~\??????t??]7a?? K~9!?
?_y.H??8??5z?%?B?w?Vy?}`!h1??? ?v?u?i????????r?&?t?"??%Om??:???a3Y??j?P7?N???(?zu???6I$Z/?"??v^??? mp??/?
h?I?'?V?9'Iexj}?z?t?S?*Y?m3i?J?H??Q???3???dUd?fk???}m????k???!H?%I>??????"???[\|*V??~J??????i-??Z??H??ayb????Ca?i^cP??i???r????????L??4??#??RH???(?Jb??[f??N?1;???&.
???Q???~~???e;?&[? ???0>wRI???s??c%"r???x??n?r}?b??j?h?MO???? q??'?#v$?????g?Xd?h?Pl:?M?\???9B5�?G?j??IE?J?~??????M ??A?<?[???/P7n??Q??0ej?_c?J?u??+J?xl???f?)?0? K?*??W519??uy??r6}?? ?N???s?)?X???????2-?j??b\????M{?f?????E?|?-???x+?zN?f�3?)^k'?qR????zevW?,d?V??????{6!?? ??#j?y?,?BZQ????!?eW???M??
U???D
Q)vWL?N?&??T?q_C?j??#?p??????V????It?.??[??-g<]i?.T�?6%|?W??n?3?x?xx??,???b&?e??Q]???Z?&l"?L???S??N ??F???+W??y??�%??Q-oc????d?S?6???/ ?_??&?t???8p??U??�Z?
?�+^???J???? r ?k??wIB?o?P?Z?]?X???c??6N??I&w?????i"I\??v2Jr?[?(??4?}?q???t?4??!?????B??<o???Q[??Q??A???mG???Q?<???f?P??
?????????Lp1??6F ?L;??J???????/????l?i??u?1??rw?
??c????????G??W??R?o?|?fz EA????JA?Z?
???0?b?EHP?p??7=?]g>d'?mk?3?5M|?E?8?_?T.?,???M?,dnP?L???hs=?;&???????(L?????4_??a?R^?LX??o?v+????7???????(?P??)b??A$?f??#?GF1S??????8b??RM.>?_?!Ab?`?Fs???+?#?HV??iM44?;u<C?????M]H?]?XQ1?f?JG????n1
?R???8?????m?<?}D???)?W3?�??k???T???SI???G??G ?hS*???bD%?=p?f2?SO?K?5??9?^8??$??v??5?7.4k%_???}?Li?h?MHqf?2q?Rj-???,'?k?o?Y_zk?W??
H?QTs>c???fx?g???D|?H?d???V?]96?3?V?1?(????u?e,?B?+ ECl7D???b?C74???l?Bt
The PDF mentions it actually:
/Producer ([ClibPDF Library 2.02-r1-2] Windows XP)
ClibPDF support for PHP was moved into PECL a long time ago (with PHP 5.1). The extension was not object oriented, so here is some additional wrapper around it.
Alternatives are Haru, PDFlib, or one of the available PHP based libraries.
I would export programmatically (in PHP) the content of a SWF file to a SVG format. So, I tried first to export each shapes composing my file to be abble to create the static sprites later.
For that, I use the IO_SWF library to read the content of the swf file.
FillStyles:
[1] solid fill: #d9d2c5(ff)
[2] solid fill: #8e7e66(ff)
[3] solid fill: #b9ae9a(ff)
[4] solid fill: #716044(ff)
LineStyles:
(none)
ShapeRecords:
ChangeStyle: MoveTo: (6.95, -10) FillStyle: 0|2 LineStyle: 0
StraightEdge: MoveTo: (7, -9.95)
StraightEdge: MoveTo: (7.2, -9.65)
StraightEdge: MoveTo: (7.1, -9.45)
StraightEdge: MoveTo: (6.85, -9)
ChangeStyle: MoveTo: (6.85, -9) FillStyle: 0|3 LineStyle: 0
CurvedEdge: MoveTo: Control(6.8, -7.95) Anchor(6.9, -7.15)
StraightEdge: MoveTo: (6.95, -6.25)
StraightEdge: MoveTo: (6.95, -6.15)
StraightEdge: MoveTo: (7, -6.15)
ChangeStyle: MoveTo: (7, -6.15) FillStyle: 0|1 LineStyle: 0
StraightEdge: MoveTo: (6.95, -5.85)
ChangeStyle: MoveTo: (6.95, -5.85) FillStyle: 0|2 LineStyle: 0
StraightEdge: MoveTo: (6.5, -5.2)
StraightEdge: MoveTo: (4.15, -2.3)
StraightEdge: MoveTo: (3.55, -2.15)
ChangeStyle: MoveTo: (3.55, -2.15) FillStyle: 0|4 LineStyle: 0
CurvedEdge: MoveTo: Control(3.7, -3.9) Anchor(5.35, -8.85)
StraightEdge: MoveTo: (6.45, -10.85)
CurvedEdge: MoveTo: Control(6.55, -10.45) Anchor(6.95, -10)
ChangeStyle: MoveTo: (6.95, -10) FillStyle: 2|4 LineStyle: 0
StraightEdge: MoveTo: (6.2, -8.9)
ChangeStyle: MoveTo: (6.2, -8.9) FillStyle: 2|3 LineStyle: 0
StraightEdge: MoveTo: (6.85, -9)
ChangeStyle: MoveTo: (6.2, -8.9) FillStyle: 3|4 LineStyle: 0
StraightEdge: MoveTo: (6.15, -7.85)
StraightEdge: MoveTo: (6.15, -7.7)
StraightEdge: MoveTo: (6.2, -7.55)
StraightEdge: MoveTo: (6.2, -6.9)
StraightEdge: MoveTo: (6.25, -6.75)
ChangeStyle: MoveTo: (6.25, -6.75) FillStyle: 3|1 LineStyle: 0
StraightEdge: MoveTo: (6.35, -6.2)
CurvedEdge: MoveTo: Control(6.4, -6) Anchor(6.7, -5.95)
StraightEdge: MoveTo: (7, -6.15)
ChangeStyle: MoveTo: (4.4, -3.2) FillStyle: 2|4 LineStyle: 0
StraightEdge: MoveTo: (4.15, -2.95)
StraightEdge: MoveTo: (3.55, -2.15)
ChangeStyle: MoveTo: (6.95, -5.85) FillStyle: 2|1 LineStyle: 0
StraightEdge: MoveTo: (6.95, -5.9)
StraightEdge: MoveTo: (6.8, -5.95)
StraightEdge: MoveTo: (6.7, -5.95)
StraightEdge: MoveTo: (6.5, -5.9)
StraightEdge: MoveTo: (6.3, -5.8)
StraightEdge: MoveTo: (4.4, -3.2)
ChangeStyle: MoveTo: (4.4, -3.2) FillStyle: 4|1 LineStyle: 0
StraightEdge: MoveTo: (6.15, -5.85)
StraightEdge: MoveTo: (6.25, -6.75)
ChangeStyle: MoveTo: (0, 0) FillStyle: 0|0 LineStyle: 0
After some research, I understood how to build a svg (composed by path tags) from these data.
ChangeStyle => start a new path => M x,y
StraightEdge => line => L x,y
CurvedEdge => curve => Q cx,cy,ax,ay
And for each path:
FillStyle: {FillStyle0} | {FillStyle1} (0 => no fill style)
The index is related to the FillStyles array
LineStyle: {LineStyle} (0 => line style)
The index is related to the LineStyles array
But this is not the correct way to browse the structure.
Using JPEXS Decompiler to manually export the previous sample shape, I get a perfect traced SVG.
Here is a comparative:
My result vs what is expected
My resulting svg:
<path fill="rgba(185, 174, 154, 1)" fill-rule="evenodd" stroke="none" d="M 6.95 -10 L 7 -9.95 L 7.2 -9.65 L 7.1 -9.45 L 6.85 -9 L 6.95 -10" />
<path fill="rgba(217, 210, 197, 1)" fill-rule="evenodd" stroke="none" d="M 6.85 -9 Q 6.8 -7.95 6.9 -7.15 L 6.95 -6.25 L 6.95 -6.15 L 7 -6.15 L 6.85 -9" />
<path fill="rgba(142, 126, 102, 1)" fill-rule="evenodd" stroke="none" d="M 7 -6.15 L 6.95 -5.85 L 7 -6.15" />
<path fill="rgba(113, 96, 68, 1)" fill-rule="evenodd" stroke="none" d="M 6.95 -5.85 L 6.5 -5.2 L 4.15 -2.3 L 3.55 -2.15 L 6.95 -5.85" />
<path fill="rgba(142, 126, 102, 1)" fill-rule="evenodd" stroke="none" d="M 3.55 -2.15 Q 3.7 -3.9 5.35 -8.85 L 6.45 -10.85 Q 6.55 -10.45 6.95 -10 L 3.55 -2.15" />
<path fill="rgba(142, 126, 102, 1)" fill-rule="evenodd" stroke="none" d="M 6.95 -10 L 6.2 -8.9 L 6.95 -10" />
<path fill="rgba(185, 174, 154, 1)" fill-rule="evenodd" stroke="none" d="M 6.2 -8.9 L 6.85 -9 L 6.2 -8.9" />
<path fill="rgba(185, 174, 154, 1)" fill-rule="evenodd" stroke="none" d="M 6.2 -8.9 L 6.15 -7.85 L 6.15 -7.7 L 6.2 -7.55 L 6.2 -6.9 L 6.25 -6.75 L 6.2 -8.9" />
<path fill="rgba(142, 126, 102, 1)" fill-rule="evenodd" stroke="none" d="M 6.25 -6.75 L 6.35 -6.2 Q 6.4 -6 6.7 -5.95 L 7 -6.15 L 6.25 -6.75" />
<path fill="rgba(142, 126, 102, 1)" fill-rule="evenodd" stroke="none" d="M 4.4 -3.2 L 4.15 -2.95 L 3.55 -2.15 L 4.4 -3.2" />
<path fill="rgba(113, 96, 68, 1)" fill-rule="evenodd" stroke="none" d="M 6.95 -5.85 L 6.95 -5.9 L 6.8 -5.95 L 6.7 -5.95 L 6.5 -5.9 L 6.3 -5.8 L 4.4 -3.2 L 6.95 -5.85" />
And the JPEXS result:
<path d="M7.0 -6.15 L6.95 -5.85 6.95 -5.9 6.8 -5.95 6.7 -5.95 6.5 -5.9 6.3 -5.8 4.4 -3.2 6.15 -5.85 6.25 -6.75 6.35 -6.2 Q6.4 -6.0 6.7 -5.95 L7.0 -6.15" fill="#d9d2c5" fill-rule="evenodd" stroke="none" />
<path d="M6.95 -10.0 L7.0 -9.95 7.2 -9.65 7.1 -9.45 6.85 -9.0 6.2 -8.9 6.95 -10.0 M6.95 -5.85 L6.5 -5.2 4.15 -2.3 3.55 -2.15 4.15 -2.95 4.4 -3.2 6.3 -5.8 6.5 -5.9 6.7 -5.95 6.8 -5.95 6.95 -5.9 6.95 -5.85" fill="#8e7e66" fill-rule="evenodd" stroke="none" />
<path d="M6.85 -9.0 Q6.8 -7.95 6.9 -7.15 L6.95 -6.25 6.95 -6.15 7.0 -6.15 6.7 -5.95 Q6.4 -6.0 6.35 -6.2 L6.25 -6.75 6.2 -6.9 6.2 -7.55 6.15 -7.7 6.15 -7.85 6.2 -8.9 6.85 -9.0" fill="#b9ae9a" fill-rule="evenodd" stroke="none" />
<path d="M3.55 -2.15 Q3.7 -3.9 5.35 -8.85 L6.45 -10.85 Q6.55 -10.45 6.95 -10.0 L6.2 -8.9 6.15 -7.85 6.15 -7.7 6.2 -7.55 6.2 -6.9 6.25 -6.75 6.15 -5.85 4.4 -3.2 4.15 -2.95 3.55 -2.15" fill="#716044" fill-rule="evenodd" stroke="none" />
All in all, how could I obtain the same well formed SVG from my data structure? I'm pretty sure there's a subtility with FillStyle0 and FillStyle1, but which?
Thanks for your help.
Sometimes I click the (symfony2 & the back-end I use sonata admin) debug toolbar button it display blank:
display nothing(check the image here)
Here is source of Firefox , it's broken here(in a svg tag):
</div>
<div id="content">
<div id="header" class="clear-fix">
<h1>
<svg width="275" height="62" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 275 62" enable-background="new 0 0 275 62" xml:space="preserve"><path fill="#010202" d="M31 0C13.9 0 0 13.9 0 31c0 17.1 13.9 31 31 31c17.1 0 31-13.9 31-31C62 13.9 48.1 0 31 0z M47.7 17.9 c-1.4 0-2.4-0.8-2.5-2.1c0-0.5 0.1-0.9 0.4-1.4c0.3-0.6 0.4-0.7 0.4-1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1 0-0.2 0 c-0.6 0-1.1 0.4-1.2 1.1l-0.1 0.9c0.5 0.1 1 0.2 1.9 0.2c3.6 0 4.7-3.3 5.7-6.1l5.5-15.2L179.4 25.4L179.4 25.4z"/></g><g><path fill="#ADADAD" d="M185.7 46.4V25.1h2.4v2c0.6-0.8 1.2-1.4 1.9-1.8c0.7-0.4 1.6-0.6 2.6-0.6c1.3 0 2.5 0.3 3.5 1 c1 0.7 1.8 1.6 2.3 2.9c0.5 1.2 0.8 2.6 0.8 4.1c0 1.6-0.3 3-0.8 4.3c-0.6 1.3-1.4 2.2-2.5 2.9c-1.1 0.7-2.2 1-3.4 1 c-0.9 0-1.7-0.2-2.3-0.6c-0.7-0.4-1.3-0.8-1.7-1.4v7.5H185.7z M188.1 32.8c0 2 0.4 3.4 1.2 4.4s1.8 1.4 2.9 1.4 c1.2 0 2.2-0.5 3-1.5c0.8-1 1.2-2.5 1.2-4.6c0-2-0.4-3.4-1.2-4.4c-0.8-1-1.8-1.5-2.9-1.5c-1.1 0-2.1 0.5-3 1.6 C188.5 29.4 188.1 30.9 188.1 32.8z"/><path fill="#ADADAD" d="M202.2 40.5V25.1h2.4v2.3c0.6-1.1 1.2-1.8 1.7-2.2c0.5-0.3 1.1-0.5 1.7-0.5c0.9 0 1.8 0.3 2.7 0.8l-0.9 2.4 c-0.6-0.4-1.3-0.6-1.9-0.6c-0.6 0-1.1 0.2-1.5 0.5c-0.5 0.3
In a svg tag(check the image here)
It's make me confused for a long time. Who can tell me why?
I have parsed some data from a file into a string variable,
CPU NFS CIFS HTTP Total Net kB/s HDD kB/s SSD kB/s Tape kB/s Cache Cache CP CP HDD SSD OTHER FCP iSCSI FCP kB/s iSCSI kB/s
in out read write read write read write age hit time ty util util in out in out
65% 0 0 0 11357 97020 2846 0 156160 0 0 0 0 >60 100% 100% :f 45% 0% 3 0 11354 0 0 92987 0
67% 0 0 0 11761 100535 2943 511 161119 0 0 0 0 >60 100% 100% :f 43% 0% 0 0 11761 0 0 96397 0
66% 0 0 0 11911 101736 2984 276 151088 0 0 0 0 >60 100% 100% :v 48% 0% 0 0 11911 0 0 97534 0
56% 0 0 0 12026 102664 3094 36 24 0 0 0 0 >60 100% 1% : 2% 0% 11 0 12015 0 0 98419 0
81% 0 0 0 10023 85660 2317 1964 198416 0 0 0 0 >60 100% 83% Ff 60% 0% 0 0 10023 0 0 82117 0
67% 0 0 0 11914 101825 2993 336 152883 0 0 0 0 >60 100% 100% :f 55% 0% 0 0 11914 0 0 97625 0
67% 0 0 0 11526 98491 2869 256 151040 0 0 0 0 >60 100% 100% :f 51% 0% 0 0 11526 0 0 94388 0
66% 0 0 0 11589 99011 2931 0 143225 0 0 0 0 >60 100% 100% :f 51% 0% 0 0 11589 0 0 94949 0
57% 0 0 0 11869 101355 3032 56 20544 0 0 0 0 >60 100% 26% : 10% 0% 7 0 11862 0 0 97182 0
76% 0 0 0 9408 79189 2212 2022 122504 0 0 0 0 >60 100% 48% Fn 38% 0% 223 0 9185 0 0 75939 0
74% 0 0 0 10978 92981 2651 572 147078 0 0 0 0 >60 100% 100% :f 53% 0% 19 0 10959 0 0 89095 0
67% 0 0 0 11839 101109 2946 8 148332 0 0 0 0 >60 100% 100% :f 56% 0% 0 0 11839 0 0 96954 0
64% 0 0 0 11517 98413 2899 256 138248 0 0 0 0 >60 100% 100% :f 51% 0% 0 0 11517 0 0 94355 0
62% 0 0 0 11653 99151 2920 559 106198 0 0 0 0 >60 100% 81% : 40% 0% 52 0 11601 0 0 95030 0
56% 0 0 0 11765 99752 2973 577 3009 0 0 0 0 >60 100% 3% Fn 2% 0% 100 0 11665 0 0 95652 0
82% 0 0 0 9987 85219 2327 1570 207259 0 0 0 0 >60 100% 100% :f 60% 0% 5 0 9982 0 0 81692 0
67% 0 0 0 11859 101347 2970 0 158696 0 0 0 0 >60 100% 100% :f 57% 0% 0 0 11859
Into a 2D Array, so that I can take average of one of the column ,
Can someone let me know how it is done ?
My code:
preg_match('/'.preg_quote($word1).'(.*?)'.preg_quote($word2).'/is', $akshay_file, $match);
$text2 = nl2br($match[1]);
echo "$text2";
Can someone let me know how it is done, am I doing it the wrong way?
Thanks.
Guess you are reading this from a file. As an option, read the file line by line and consider the following code
<?php
$n = "65% 0 0 0 11357 97020 2846 0 156160 0 0 0 0 >60 100% 100% :f 45% 0% 3 0 11354 0 0 92987 0";
$n = preg_replace('!\s+!', ' ', $n);
$parts = explode(' ', $n);
echo '<pre>'.print_r($parts, true).'</pre>';
?>
At first you should split the code in lines and then split each line by whitespaces.
$lines = preg_split('/$\R?^/m', $data);
foreach ($lines as $line) {
$cols = preg_split('/\s\s+/', $data);
// do sth..
}
I want to do a stress test on an Apache webserver that I have running on localhost. The test will request the webserver to execute a PHP application that I wrote. I want to see how much memory (RAM) the webserver (and/or the associated PHP process) consumes during the test. Or to see how much it consumed after the test is done.
My OS is Ubuntu 13.10.
I looked at Apache Bench, Apache JMeter, Siege and httperf. None of them seem to provide such information. At most, I can see some CPU load in httperf (which in most cases is 100 %, so not too relevant).
Is there some tool that can provide me with memory consumption information ? It doesn't have to be a webserver benchmarking tool, could also be another Linux software that runs in parallel with the benchmarking tool. I just think that manually monitoring the test via the top command is kind of innacurate/ammateurish. Thank you in advance.
htop may be exactly what you're looking for.
Personally, I recently discovered something called byobu - which gives you a handy readout on the bottom (which you can configure by pressing F9) --
And that has become my personal favorite for exactly what you're describing.
Although, you could also look into xdebug -- and use something like xdebug_memory_usage() -- in the php script you're testing to dump info into a log file at key points in your script
I've put up a few PHP cronjobs, too, when I manually start the script through console I want to see debug and stuff, too.
I put in a method like this:
protected $consoleUpdate;
protected function printMemoryUsage() {
if ((time() - $this->consoleUpdate) >= 3) {
$this->consoleUpdate = time();
echo "Memory: ",
round(memory_get_usage(true) / (1024 * 1024)),
" MB",
"\r";
}
}
Call this method as often as you like to print the scripts memory usage.
Notice the final \r in the console, which returns the cursor to the line beginning and overwrites the line. If you don't have any other output, this has the effect of your screen not moving, instead, it gets updated.
Things like top, htop, memstat, iotop, mysqltop. All these tools are excellent to see what is thoroughly cooking your server while you throw siege (and its friend apachebench) at it.
I use vmstat for memory, disk and CPU monitoring. Below are some measurements whilst copying files on a bottom of the heap Linux based Raspberry Pi. I first used vmstat in the 1980’s, monitoring DB activity on early Unix systems. More details in:
http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm
vmstat was either run from a separate terminal or in a combined script file.
pi#raspberrypi /mnt $ time sudo sh -c "cp -r 256k /mnt/new2 && sync"
40 samles at 1 second intervals
vmstat 1 40 > vmstatRes.txt
real 0m38.781s
user 0m0.400s
sys 0m8.400s
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 0 304684 15208 65952 0 0 0 0 1109 319 39 2 59 0
1 0 0 282788 15208 87308 0 0 10292 0 4018 2994 5 57 9 29
1 1 0 256996 15208 112768 0 0 12380 0 4687 3863 3 53 0 44
2 2 0 231452 15212 138028 0 0 12288 40 4781 4024 5 55 0 40
0 1 0 216576 15216 152476 0 0 7004 10512 5649 3580 5 50 0 46
2 2 0 201688 15216 167288 0 0 7144 17488 5341 3527 2 52 0 46
1 0 0 195064 15216 173808 0 0 3192 9016 5909 3214 2 34 0 64
3 0 0 169520 15216 199152 0 0 12304 0 4704 3914 2 60 0 38
2 3 0 149988 15220 218288 0 0 9252 9892 5003 3614 2 52 0 45
0 2 0 131008 15224 237072 0 0 9112 10324 5086 3568 2 54 0 44
1 0 0 120160 15224 247784 0 0 5232 0 4976 2935 0 34 0 66
0 1 0 110424 15224 257404 0 0 4628 12864 5097 3034 4 36 0 60
1 0 0 86556 15224 281120 0 0 11536 0 4965 3874 3 54 0 43
1 1 0 73784 15224 293816 0 0 6188 11592 5545 3514 2 46 0 52
1 1 0 63252 15232 304132 0 0 4968 10320 4617 2748 2 34 0 64
0 1 0 43148 15232 323960 0 0 9652 7184 5126 3749 2 54 0 43
0 1 0 29336 15232 337560 0 0 6596 10036 4311 2796 2 38 0 59
1 1 0 23944 11696 346276 0 0 7480 0 5465 3455 2 46 0 52
2 1 0 23076 9580 349184 0 0 2860 10524 4521 2323 1 35 0 64
2 1 0 24440 5300 351508 0 0 8864 5188 4586 3215 1 66 0 33
0 1 0 24500 3900 352704 0 0 4896 11448 5974 3308 2 49 0 49
1 1 0 24432 3772 352700 0 0 10424 6208 4851 3682 2 60 0 38
1 1 0 23764 3772 353736 0 0 6568 5184 5970 3526 1 45 0 53
1 1 0 24068 3776 353500 0 0 4900 11388 5449 3142 0 40 0 60
0 1 0 24400 3780 352552 0 0 10068 8848 4821 3531 2 57 0 40
1 1 0 24152 3772 352588 0 0 8292 2784 5207 3588 2 50 0 48
1 1 0 23516 3772 353620 0 0 6800 7816 5475 3475 1 49 0 49
0 1 0 24260 3772 352940 0 0 7004 7424 5042 3284 4 43 0 52
2 1 0 24068 3776 353060 0 0 4624 10292 4798 2801 0 39 0 61
2 0 0 23820 3780 353340 0 0 8844 5508 5251 3609 0 56 0 44
2 1 0 24252 3772 352528 0 0 4552 12000 5053 2841 2 44 0 54
1 1 0 23696 3772 353120 0 0 10880 2176 4908 3694 2 58 0 40
1 0 0 24260 3772 352212 0 0 3748 11104 5208 2904 2 34 0 63
3 2 0 24136 3780 352084 0 0 10148 1628 4637 3568 1 55 0 44
0 1 0 24192 3780 352120 0 0 4016 10260 4719 2613 1 31 0 68
1 1 0 24392 3772 352076 0 0 6804 10972 5386 3473 1 52 0 47
1 1 0 24392 3772 351704 0 0 8568 8788 5101 3502 2 61 0 36
0 1 0 24376 3780 351764 0 0 0 30036 6711 1888 0 36 0 64
0 1 0 24252 3780 351928 0 0 28 2072 5629 1354 0 10 0 90
0 0 0 24768 3780 351968 0 0 40 20 1351 579 9 6 13 72
1 0 0 24768 3780 351968 0 0 0 0 1073 55 1 1 98 0