public function createThali($dishArray = array(), $is_thali, $w = 140, $h = 0) { Configure::write('debug', 2); ini_set("max_execution_time", -1); $thali1 = new Imagick("tmpl/img/thali-1.png"); $thali2 = new Imagick("tmpl/img/thali-2.png"); $thali3 = new Imagick("tmpl/img/thali-3.png"); $mask_1 = new Imagick("tmpl/img/thali-mask2.png"); $mask_2 = new Imagick("tmpl/img/thali-mask3.png"); if (!is_array($dishArray)) { return false; } $mask_cnt = 0; foreach ($dishArray as $dish) { if ($mask_cnt > 1) { // Mask Locking (Modify if masks will be increased or decreased) break; } $dish = new Imagick($dish); $dish->scaleimage($thali1->getimagewidth(), $thali1->getimageheight()); // Set As per bowl image if ($is_thali) { if ($mask_cnt == 1) { $dish->rotateimage("#fff", 180); } $dish->compositeimage(new Imagick("tmpl/img/thali-mask" . ($mask_cnt + 2) . ".png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA); $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $thali1->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA); $thali1->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $thali2->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA); $thali2->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $thali3->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA); $thali3->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); } else { $thali3 = $dish; } $mask_cnt++; } $url = "files/thali_images/" . $this->randomString(6); $url_end = "-Thali.jpg"; $result_urls = array(); $thali1->setimageformat("jpg"); $thali1->setImageFileName($result_urls[] = $url . "-0" . $url_end); $thali1->scaleimage($w, $h); if ($is_thali) { $thali2->writeimage(); } $thali1->destroy(); $thali2->setimageformat("jpg"); $thali2->setImageFileName($result_urls[] = $url . "-1" . $url_end); $thali2->scaleimage($w, $h); if ($is_thali) { $thali2->writeimage(); } $thali2->destroy(); $thali3->setimageformat("jpg"); $thali3->setImageFileName($result_urls[] = $url . "-2" . $url_end); $thali3->scaleimage($w, $h); $thali3->writeimage(); $thali3->destroy(); return $result_urls; }
public function gentom() { $sw = '{"d7c8b5":{"file":"01-d7c8b5.png","id":1},"d2b9a0":{"file":"02-d2b9a0.png","id":2},"cbb79c":{"file":"03-cbb79c.png","id":3},"b8a28c":{"file":"04-b8a28c.png","id":4},"ddbf9e":{"file":"05-ddbf9e.png","id":5},"d1b293":{"file":"06-d1b293.png","id":6},"cfa690":{"file":"07-cfa690.png","id":7},"dab084":{"file":"08-dab084.png","id":8},"b69b76":{"file":"09-b69b76.png","id":9},"6b5b4b":{"file":"10-6b5b4b.png","id":10},"501d24":{"file":"11-501d24.png","id":11},"4d1b22":{"file":"12-4d1b22.png","id":12},"3f2022":{"file":"13-3f2022.png","id":13},"431e22":{"file":"14-431e22.png","id":14},"622430":{"file":"15-622430.png","id":15},"621b24":{"file":"16-621b24.png","id":16},"7e1f33":{"file":"17-7e1f33.png","id":17},"99232d":{"file":"18-99232d.png","id":18},"be3849":{"file":"19-be3849.png","id":19},"a62d46":{"file":"20-a62d46.png","id":20},"e3cfb7":{"file":"21-e3cfb7.png","id":21},"d0b79e":{"file":"22-d0b79e.png","id":22},"dbb086":{"file":"23-dbb086.png","id":23},"dbb89c":{"file":"24-dbb89c.png","id":24},"c39b78":{"file":"25-c39b78.png","id":25},"d4b194":{"file":"26-d4b194.png","id":26},"c3976d":{"file":"27-c3976d.png","id":27},"b6906b":{"file":"28-b6906b.png","id":28},"73533c":{"file":"29-73533c.png","id":29},"604742":{"file":"30-604742.png","id":30},"542126":{"file":"31-542126.png","id":31},"4e2426":{"file":"32-4e2426.png","id":32},"441e26":{"file":"33-441e26.png","id":33},"471a1e":{"file":"34-471a1e.png","id":34},"731727":{"file":"35-731727.png","id":35},"a7282d":{"file":"36-a7282d.png","id":36},"a12227":{"file":"37-a12227.png","id":37},"a33145":{"file":"38-a33145.png","id":38},"cf6672":{"file":"39-cf6672.png","id":39},"a03856":{"file":"40-a03856.png","id":40},"d0b99b":{"file":"41-d0b99b.png","id":41},"e2ba94":{"file":"42-e2ba94.png","id":42},"d2ae8f":{"file":"43-d2ae8f.png","id":43},"d5a47a":{"file":"44-d5a47a.png","id":44},"d4a47c":{"file":"45-d4a47c.png","id":45},"bb9973":{"file":"46-bb9973.png","id":46},"b29273":{"file":"47-b29273.png","id":47},"906d53":{"file":"48-906d53.png","id":48},"ae7549":{"file":"49-ae7549.png","id":49},"a57a50":{"file":"50-a57a50.png","id":50},"441c21":{"file":"51-441c21.png","id":51},"3f171c":{"file":"52-3f171c.png","id":52},"5a2730":{"file":"53-5a2730.png","id":53},"861b29":{"file":"54-861b29.png","id":54},"cc4046":{"file":"55-cc4046.png","id":55},"d83f45":{"file":"56-d83f45.png","id":56},"ce2e33":{"file":"57-ce2e33.png","id":57},"f59185":{"file":"58-f59185.png","id":58},"d84c60":{"file":"59-d84c60.png","id":59},"262724":{"file":"60-262724.png","id":60},"dcb585":{"file":"61-dcb585.png","id":61},"b7946e":{"file":"62-b7946e.png","id":62},"daa989":{"file":"63-daa989.png","id":63},"d8a47c":{"file":"64-d8a47c.png","id":64},"bd9b80":{"file":"65-bd9b80.png","id":65},"a77d5d":{"file":"66-a77d5d.png","id":66},"7c5946":{"file":"67-7c5946.png","id":67},"c5985b":{"file":"68-c5985b.png","id":68},"845a44":{"file":"69-845a44.png","id":69},"a7764c":{"file":"145-a7764c.png","id":145},"482327":{"file":"71-482327.png","id":71},"823133":{"file":"72-823133.png","id":72},"791b27":{"file":"73-791b27.png","id":73},"891d2f":{"file":"74-891d2f.png","id":74},"91413d":{"file":"75-91413d.png","id":75},"b01f2c":{"file":"76-b01f2c.png","id":76},"df5d5b":{"file":"77-df5d5b.png","id":77},"e76269":{"file":"78-e76269.png","id":78},"2c2c2e":{"file":"79-2c2c2e.png","id":79},"232c39":{"file":"80-232c39.png","id":80},"be9b77":{"file":"81-be9b77.png","id":81},"b79372":{"file":"82-b79372.png","id":82},"b78b63":{"file":"83-b78b63.png","id":83},"c8a17b":{"file":"84-c8a17b.png","id":84},"c09469":{"file":"85-c09469.png","id":85},"8d6c4f":{"file":"86-8d6c4f.png","id":86},"bf9e59":{"file":"87-bf9e59.png","id":87},"9c6a48":{"file":"88-9c6a48.png","id":88},"9a7251":{"file":"89-9a7251.png","id":89},"956846":{"file":"90-956846.png","id":90},"692328":{"file":"91-692328.png","id":91},"751c27":{"file":"92-751c27.png","id":92},"a32734":{"file":"93-a32734.png","id":93},"a2373e":{"file":"94-a2373e.png","id":94},"c14840":{"file":"95-c14840.png","id":95},"d16068":{"file":"96-d16068.png","id":96},"c67463":{"file":"97-c67463.png","id":97},"2b2728":{"file":"98-2b2728.png","id":98},"222a3f":{"file":"99-222a3f.png","id":99},"1d2f3f":{"file":"100-1d2f3f.png","id":100},"ae8a6f":{"file":"101-ae8a6f.png","id":101},"b78a69":{"file":"102-b78a69.png","id":102},"b69468":{"file":"103-b69468.png","id":103},"ba9b81":{"file":"104-ba9b81.png","id":104},"8c6f57":{"file":"105-8c6f57.png","id":105},"bf9564":{"file":"106-bf9564.png","id":106},"ab793d":{"file":"107-ab793d.png","id":107},"af7a51":{"file":"108-af7a51.png","id":108},"7e553c":{"file":"109-7e553c.png","id":109},"986646":{"file":"110-986646.png","id":110},"811d2c":{"file":"111-811d2c.png","id":111},"782b2e":{"file":"112-782b2e.png","id":112},"743030":{"file":"113-743030.png","id":113},"c46b66":{"file":"114-c46b66.png","id":114},"e95c67":{"file":"115-e95c67.png","id":115},"e88188":{"file":"116-e88188.png","id":116},"262728":{"file":"117-262728.png","id":117},"1f2332":{"file":"118-1f2332.png","id":118},"222d46":{"file":"119-222d46.png","id":119},"2c3b47":{"file":"120-2c3b47.png","id":120},"ac805e":{"file":"121-ac805e.png","id":121},"a98e76":{"file":"122-a98e76.png","id":122},"aa876c":{"file":"123-aa876c.png","id":123},"9a785e":{"file":"124-9a785e.png","id":124},"b08a4b":{"file":"125-b08a4b.png","id":125},"a17548":{"file":"126-a17548.png","id":126},"806049":{"file":"127-806049.png","id":127},"735550":{"file":"128-735550.png","id":128},"5d3c32":{"file":"129-5d3c32.png","id":129},"41322f":{"file":"130-41322f.png","id":130},"682d2c":{"file":"131-682d2c.png","id":131},"692122":{"file":"132-692122.png","id":132},"9a4544":{"file":"133-9a4544.png","id":133},"863645":{"file":"134-863645.png","id":134},"ef9692":{"file":"135-ef9692.png","id":135},"342a2c":{"file":"136-342a2c.png","id":136},"222629":{"file":"137-222629.png","id":137},"232a42":{"file":"138-232a42.png","id":138},"2b3648":{"file":"139-2b3648.png","id":139},"53598e":{"file":"140-53598e.png","id":140},"9c7d5d":{"file":"141-9c7d5d.png","id":141},"977561":{"file":"142-977561.png","id":142},"9e7b67":{"file":"143-9e7b67.png","id":143},"99784f":{"file":"144-99784f.png","id":144},"6e5045":{"file":"146-6e5045.png","id":146},"634126":{"file":"147-634126.png","id":147},"563824":{"file":"148-563824.png","id":148},"48342b":{"file":"149-48342b.png","id":149},"b06a62":{"file":"150-b06a62.png","id":150},"9e484b":{"file":"151-9e484b.png","id":151},"b0544e":{"file":"152-b0544e.png","id":152},"e4699f":{"file":"153-e4699f.png","id":153},"e991b0":{"file":"154-e991b0.png","id":154},"252526":{"file":"155-252526.png","id":155},"202934":{"file":"156-202934.png","id":156},"2e3b54":{"file":"157-2e3b54.png","id":157},"2e404a":{"file":"158-2e404a.png","id":158},"576e8e":{"file":"159-576e8e.png","id":159},"28487a":{"file":"160-28487a.png","id":160},"9d856b":{"file":"161-9d856b.png","id":161},"96704b":{"file":"162-96704b.png","id":162},"b98d62":{"file":"163-b98d62.png","id":163},"a47041":{"file":"164-a47041.png","id":164},"814230":{"file":"165-814230.png","id":165},"574231":{"file":"166-574231.png","id":166},"443025":{"file":"167-443025.png","id":167},"3f2c25":{"file":"168-3f2c25.png","id":168},"b85650":{"file":"169-b85650.png","id":169},"ad6b45":{"file":"170-ad6b45.png","id":170},"d63c86":{"file":"171-d63c86.png","id":171},"de5693":{"file":"172-de5693.png","id":172},"f59aa5":{"file":"173-f59aa5.png","id":173},"343241":{"file":"174-343241.png","id":174},"2c3742":{"file":"175-2c3742.png","id":175},"263147":{"file":"176-263147.png","id":176},"295074":{"file":"177-295074.png","id":177},"5c70ac":{"file":"178-5c70ac.png","id":178},"3b5d82":{"file":"179-3b5d82.png","id":179},"656d8d":{"file":"180-656d8d.png","id":180},"9f7859":{"file":"181-9f7859.png","id":181},"937144":{"file":"182-937144.png","id":182},"966b44":{"file":"183-966b44.png","id":183},"854b23":{"file":"184-854b23.png","id":184},"713f25":{"file":"185-713f25.png","id":185},"472e26":{"file":"186-472e26.png","id":186},"33251f":{"file":"187-33251f.png","id":187},"984538":{"file":"188-984538.png","id":188},"5d372d":{"file":"189-5d372d.png","id":189},"683d26":{"file":"190-683d26.png","id":190},"f79d84":{"file":"191-f79d84.png","id":191},"e1a59a":{"file":"192-e1a59a.png","id":192},"2b3039":{"file":"193-2b3039.png","id":193},"262d3b":{"file":"194-262d3b.png","id":194},"293b59":{"file":"195-293b59.png","id":195},"355888":{"file":"196-355888.png","id":196},"516076":{"file":"197-516076.png","id":197},"515368":{"file":"198-515368.png","id":198},"4c6082":{"file":"199-4c6082.png","id":199},"4870a0":{"file":"200-4870a0.png","id":200},"9c713a":{"file":"201-9c713a.png","id":201},"b7957a":{"file":"202-b7957a.png","id":202},"a5693f":{"file":"203-a5693f.png","id":203},"804a2e":{"file":"204-804a2e.png","id":204},"603b29":{"file":"205-603b29.png","id":205},"4c3629":{"file":"206-4c3629.png","id":206},"78383a":{"file":"207-78383a.png","id":207},"5a3c20":{"file":"208-5a3c20.png","id":208},"6d3f2d":{"file":"209-6d3f2d.png","id":209},"9f2e26":{"file":"210-9f2e26.png","id":210},"e1b1ac":{"file":"211-e1b1ac.png","id":211},"38383a":{"file":"212-38383a.png","id":212},"2d354a":{"file":"213-2d354a.png","id":213},"333959":{"file":"214-333959.png","id":214},"374974":{"file":"215-374974.png","id":215},"38486e":{"file":"216-38486e.png","id":216},"637585":{"file":"217-637585.png","id":217},"63838a":{"file":"218-63838a.png","id":218},"4e7cbe":{"file":"219-4e7cbe.png","id":219},"7399b3":{"file":"220-7399b3.png","id":220},"ab8b56":{"file":"221-ab8b56.png","id":221},"aa6d32":{"file":"222-aa6d32.png","id":222},"8b4933":{"file":"223-8b4933.png","id":223},"743f33":{"file":"224-743f33.png","id":224},"44332b":{"file":"225-44332b.png","id":225},"9b3d36":{"file":"226-9b3d36.png","id":226},"624229":{"file":"227-624229.png","id":227},"53392d":{"file":"228-53392d.png","id":228},"a73c23":{"file":"229-a73c23.png","id":229},"c33727":{"file":"230-c33727.png","id":230},"3a3c49":{"file":"231-3a3c49.png","id":231},"282829":{"file":"232-282829.png","id":232},"2a3a59":{"file":"233-2a3a59.png","id":233},"334b77":{"file":"234-334b77.png","id":234},"4c77bb":{"file":"235-4c77bb.png","id":235},"405f7d":{"file":"236-405f7d.png","id":236},"588ebd":{"file":"237-588ebd.png","id":237},"527197":{"file":"238-527197.png","id":238},"6d92b3":{"file":"239-6d92b3.png","id":239},"8da0aa":{"file":"240-8da0aa.png","id":240},"8a573a":{"file":"241-8a573a.png","id":241},"8b4b30":{"file":"242-8b4b30.png","id":242},"3e2d26":{"file":"243-3e2d26.png","id":243},"382928":{"file":"244-382928.png","id":244},"86302c":{"file":"245-86302c.png","id":245},"b24933":{"file":"246-b24933.png","id":246},"5a4536":{"file":"247-5a4536.png","id":247},"ca4b28":{"file":"248-ca4b28.png","id":248},"8d4433":{"file":"249-8d4433.png","id":249},"da7a51":{"file":"250-da7a51.png","id":250},"2b2a30":{"file":"251-2b2a30.png","id":251},"334264":{"file":"252-334264.png","id":252},"505a6b":{"file":"253-505a6b.png","id":253},"32479a":{"file":"254-32479a.png","id":254},"3a63a5":{"file":"255-3a63a5.png","id":255},"5288a9":{"file":"256-5288a9.png","id":256},"586679":{"file":"257-586679.png","id":257},"63779b":{"file":"258-63779b.png","id":258},"9f9a9f":{"file":"259-9f9a9f.png","id":259},"98a1ab":{"file":"260-98a1ab.png","id":260},"653628":{"file":"261-653628.png","id":261},"5a382f":{"file":"262-5a382f.png","id":262},"322829":{"file":"263-322829.png","id":263},"7c3630":{"file":"264-7c3630.png","id":264},"793c2c":{"file":"265-793c2c.png","id":265},"483839":{"file":"266-483839.png","id":266},"d85527":{"file":"267-d85527.png","id":267},"ea7033":{"file":"268-ea7033.png","id":268},"c68061":{"file":"269-c68061.png","id":269},"e08862":{"file":"270-e08862.png","id":270},"354b68":{"file":"271-354b68.png","id":271},"4273b9":{"file":"293-4273b9.png","id":293},"4f5f89":{"file":"273-4f5f89.png","id":273},"445998":{"file":"274-445998.png","id":274},"2972a3":{"file":"275-2972a3.png","id":275},"4b668e":{"file":"276-4b668e.png","id":276},"789dd3":{"file":"277-789dd3.png","id":277},"a2b3bd":{"file":"278-a2b3bd.png","id":278},"b4b5b5":{"file":"279-b4b5b5.png","id":279},"cfbab5":{"file":"280-cfbab5.png","id":280},"4a3728":{"file":"281-4a3728.png","id":281},"2a2220":{"file":"282-2a2220.png","id":282},"752e26":{"file":"283-752e26.png","id":283},"70292a":{"file":"284-70292a.png","id":284},"3d3125":{"file":"285-3d3125.png","id":285},"51412b":{"file":"286-51412b.png","id":286},"8d3d2f":{"file":"287-8d3d2f.png","id":287},"f59051":{"file":"288-f59051.png","id":288},"f68b4c":{"file":"289-f68b4c.png","id":289},"fcb448":{"file":"290-fcb448.png","id":290},"5e6a6e":{"file":"291-5e6a6e.png","id":291},"275093":{"file":"292-275093.png","id":292},"4c7094":{"file":"294-4c7094.png","id":294},"5b90ab":{"file":"295-5b90ab.png","id":295},"87a5c2":{"file":"296-87a5c2.png","id":296},"78a0ca":{"file":"297-78a0ca.png","id":297},"a7aab1":{"file":"298-a7aab1.png","id":298},"c4b6ad":{"file":"299-c4b6ad.png","id":299},"d1c0b6":{"file":"300-d1c0b6.png","id":300},"cec798":{"file":"301-cec798.png","id":301},"bfc799":{"file":"302-bfc799.png","id":302},"becfa5":{"file":"303-becfa5.png","id":303},"d2debb":{"file":"304-d2debb.png","id":304},"b7b7ad":{"file":"305-b7b7ad.png","id":305},"81993c":{"file":"306-81993c.png","id":306},"7ea888":{"file":"307-7ea888.png","id":307},"6aa897":{"file":"308-6aa897.png","id":308},"94c4af":{"file":"309-94c4af.png","id":309},"e9debd":{"file":"310-e9debd.png","id":310},"f3f1d7":{"file":"311-f3f1d7.png","id":311},"fdf8e0":{"file":"312-fdf8e0.png","id":312},"fdd7a8":{"file":"313-fdd7a8.png","id":313},"faeabb":{"file":"314-faeabb.png","id":314},"fdc986":{"file":"315-fdc986.png","id":315},"fcc87c":{"file":"316-fcc87c.png","id":316},"faa962":{"file":"317-faa962.png","id":317},"ec5825":{"file":"318-ec5825.png","id":318},"ecae24":{"file":"319-ecae24.png","id":319},"a77a45":{"file":"320-a77a45.png","id":320},"c6caaa":{"file":"321-c6caaa.png","id":321},"afbea6":{"file":"322-afbea6.png","id":322},"9ec4a5":{"file":"323-9ec4a5.png","id":323},"d6e7c9":{"file":"324-d6e7c9.png","id":324},"699754":{"file":"325-699754.png","id":325},"696c40":{"file":"326-696c40.png","id":326},"629c83":{"file":"327-629c83.png","id":327},"6aae9c":{"file":"328-6aae9c.png","id":328},"96cbbe":{"file":"329-96cbbe.png","id":329},"acd0ba":{"file":"330-acd0ba.png","id":330},"f6efca":{"file":"331-f6efca.png","id":331},"ffeac6":{"file":"332-ffeac6.png","id":332},"fbd796":{"file":"333-fbd796.png","id":333},"fedb74":{"file":"334-fedb74.png","id":334},"efc25e":{"file":"335-efc25e.png","id":335},"f1b154":{"file":"336-f1b154.png","id":336},"e46225":{"file":"337-e46225.png","id":337},"e18d26":{"file":"338-e18d26.png","id":338},"9b7940":{"file":"339-9b7940.png","id":339},"b69051":{"file":"340-b69051.png","id":340},"a5c8af":{"file":"341-a5c8af.png","id":341},"b9cbb0":{"file":"342-b9cbb0.png","id":342},"91ad84":{"file":"343-91ad84.png","id":343},"597e49":{"file":"344-597e49.png","id":344},"4a6737":{"file":"345-4a6737.png","id":345},"977d3f":{"file":"346-977d3f.png","id":346},"5d9583":{"file":"347-5d9583.png","id":347},"669185":{"file":"348-669185.png","id":348},"739f86":{"file":"349-739f86.png","id":349},"b6e1d9":{"file":"350-b6e1d9.png","id":350},"fce6a4":{"file":"351-fce6a4.png","id":351},"e4be6a":{"file":"352-e4be6a.png","id":352},"fccc7f":{"file":"353-fccc7f.png","id":353},"fddb6a":{"file":"354-fddb6a.png","id":354},"fdc24e":{"file":"355-fdc24e.png","id":355},"e17927":{"file":"356-e17927.png","id":356},"ea9d21":{"file":"357-ea9d21.png","id":357},"9f7937":{"file":"358-9f7937.png","id":358},"6a492e":{"file":"359-6a492e.png","id":359},"b99153":{"file":"360-b99153.png","id":360},"909a7e":{"file":"361-909a7e.png","id":361},"8aa87c":{"file":"362-8aa87c.png","id":362},"7a8157":{"file":"363-7a8157.png","id":363},"61713a":{"file":"364-61713a.png","id":364},"897e3f":{"file":"365-897e3f.png","id":365},"796b39":{"file":"366-796b39.png","id":366},"547f55":{"file":"367-547f55.png","id":367},"4d7553":{"file":"368-4d7553.png","id":368},"4b7b65":{"file":"369-4b7b65.png","id":369},"569585":{"file":"370-569585.png","id":370},"fde495":{"file":"371-fde495.png","id":371},"f7cd68":{"file":"372-f7cd68.png","id":372},"f7c450":{"file":"373-f7c450.png","id":373},"fed959":{"file":"374-fed959.png","id":374},"f1981f":{"file":"375-f1981f.png","id":375},"d7a528":{"file":"376-d7a528.png","id":376},"d4b571":{"file":"377-d4b571.png","id":377},"c29445":{"file":"378-c29445.png","id":378},"c39e58":{"file":"379-c39e58.png","id":379},"7d5828":{"file":"380-7d5828.png","id":380},"889a80":{"file":"381-889a80.png","id":381},"aea676":{"file":"382-aea676.png","id":382},"cfbf8d":{"file":"383-cfbf8d.png","id":383},"9f9b50":{"file":"384-9f9b50.png","id":384},"5d5737":{"file":"385-5d5737.png","id":385},"636349":{"file":"386-636349.png","id":386},"43634a":{"file":"387-43634a.png","id":387},"5a856a":{"file":"388-5a856a.png","id":388},"3f6657":{"file":"389-3f6657.png","id":389},"3f715b":{"file":"390-3f715b.png","id":390},"fcd785":{"file":"391-fcd785.png","id":391},"fce284":{"file":"392-fce284.png","id":392},"fcda5f":{"file":"393-fcda5f.png","id":393},"f6841f":{"file":"394-f6841f.png","id":394},"f3b418":{"file":"395-f3b418.png","id":395},"e8c473":{"file":"396-e8c473.png","id":396},"cb9136":{"file":"397-cb9136.png","id":397},"966d40":{"file":"398-966d40.png","id":398},"95672f":{"file":"399-95672f.png","id":399},"775937":{"file":"400-775937.png","id":400},"684f2d":{"file":"401-684f2d.png","id":401},"385c38":{"file":"402-385c38.png","id":402},"385831":{"file":"403-385831.png","id":403},"405339":{"file":"404-405339.png","id":404},"485338":{"file":"405-485338.png","id":405},"51553a":{"file":"406-51553a.png","id":406},"3e6b54":{"file":"407-3e6b54.png","id":407},"355d4a":{"file":"408-355d4a.png","id":408},"527d7c":{"file":"409-527d7c.png","id":409},"326069":{"file":"410-326069.png","id":410},"fdeab0":{"file":"411-fdeab0.png","id":411},"fbe46d":{"file":"412-fbe46d.png","id":412},"f89c4f":{"file":"413-f89c4f.png","id":413},"f2b418":{"file":"414-f2b418.png","id":414},"d8b574":{"file":"415-d8b574.png","id":415},"b58935":{"file":"416-b58935.png","id":416},"c69437":{"file":"417-c69437.png","id":417},"9a7144":{"file":"418-9a7144.png","id":418},"77635d":{"file":"419-77635d.png","id":419},"8a6a71":{"file":"420-8a6a71.png","id":420},"56452f":{"file":"421-56452f.png","id":421},"54472a":{"file":"422-54472a.png","id":422},"3b4b37":{"file":"423-3b4b37.png","id":423},"2f4131":{"file":"424-2f4131.png","id":424},"2a4c33":{"file":"425-2a4c33.png","id":425},"555d3c":{"file":"426-555d3c.png","id":426},"6b654f":{"file":"427-6b654f.png","id":427},"96b2bb":{"file":"428-96b2bb.png","id":428},"7aa8bd":{"file":"429-7aa8bd.png","id":429},"45757f":{"file":"430-45757f.png","id":430},"f7e081":{"file":"431-f7e081.png","id":431},"faa847":{"file":"432-faa847.png","id":432},"e6bb1f":{"file":"433-e6bb1f.png","id":433},"e6b558":{"file":"434-e6b558.png","id":434},"a56e34":{"file":"435-a56e34.png","id":435},"c38f30":{"file":"436-c38f30.png","id":436},"e2a84c":{"file":"437-e2a84c.png","id":437},"885e2b":{"file":"438-885e2b.png","id":438},"b28f86":{"file":"439-b28f86.png","id":439},"bdaea6":{"file":"440-bdaea6.png","id":440},"4f4529":{"file":"441-4f4529.png","id":441},"573c31":{"file":"442-573c31.png","id":442},"564832":{"file":"443-564832.png","id":443},"292f28":{"file":"444-292f28.png","id":444},"314235":{"file":"445-314235.png","id":445},"495546":{"file":"446-495546.png","id":446},"87a8bc":{"file":"447-87a8bc.png","id":447},"98b7c9":{"file":"448-98b7c9.png","id":448},"9ecccf":{"file":"449-9ecccf.png","id":449},"8fbcd4":{"file":"450-8fbcd4.png","id":450},"f99f3e":{"file":"451-f99f3e.png","id":451},"f6d02a":{"file":"452-f6d02a.png","id":452},"d1a254":{"file":"453-d1a254.png","id":453},"a26b28":{"file":"454-a26b28.png","id":454},"846131":{"file":"455-846131.png","id":455},"a4723e":{"file":"456-a4723e.png","id":456},"87672e":{"file":"457-87672e.png","id":457},"987976":{"file":"458-987976.png","id":458},"b79a91":{"file":"459-b79a91.png","id":459},"7c736d":{"file":"460-7c736d.png","id":460},"5e4e2f":{"file":"461-5e4e2f.png","id":461},"4d4120":{"file":"462-4d4120.png","id":462},"413b23":{"file":"463-413b23.png","id":463},"635432":{"file":"464-635432.png","id":464},"98b9c6":{"file":"465-98b9c6.png","id":465},"a1b8c6":{"file":"466-a1b8c6.png","id":466},"93b8c4":{"file":"467-93b8c4.png","id":467},"a1b9bb":{"file":"468-a1b9bb.png","id":468},"b5beb1":{"file":"469-b5beb1.png","id":469},"cfcfce":{"file":"470-cfcfce.png","id":470},"f7cd1d":{"file":"471-f7cd1d.png","id":471},"af8a35":{"file":"472-af8a35.png","id":472},"bd8139":{"file":"473-bd8139.png","id":473},"946b42":{"file":"474-946b42.png","id":474},"8d6948":{"file":"475-8d6948.png","id":475},"95724c":{"file":"476-95724c.png","id":476},"b48fa1":{"file":"477-b48fa1.png","id":477},"6e5b5d":{"file":"478-6e5b5d.png","id":478},"a39594":{"file":"479-a39594.png","id":479},"8a7b70":{"file":"480-8a7b70.png","id":480},"564826":{"file":"481-564826.png","id":481},"50412a":{"file":"482-50412a.png","id":482},"46402a":{"file":"483-46402a.png","id":483},"504b36":{"file":"484-504b36.png","id":484},"434327":{"file":"485-434327.png","id":485},"7a9ea4":{"file":"486-7a9ea4.png","id":486},"899692":{"file":"487-899692.png","id":487},"a7b0a3":{"file":"488-a7b0a3.png","id":488},"a3b9b2":{"file":"489-a3b9b2.png","id":489},"babfbb":{"file":"490-babfbb.png","id":490},"d98f28":{"file":"491-d98f28.png","id":491},"c88443":{"file":"492-c88443.png","id":492},"a77329":{"file":"493-a77329.png","id":493},"916c29":{"file":"494-916c29.png","id":494},"6e523c":{"file":"495-6e523c.png","id":495},"998598":{"file":"496-998598.png","id":496},"c0ad9d":{"file":"497-c0ad9d.png","id":497},"c8b8b5":{"file":"498-c8b8b5.png","id":498},"6c6c63":{"file":"499-6c6c63.png","id":499},"565459":{"file":"500-565459.png","id":500},"967d59":{"file":"501-967d59.png","id":501},"847554":{"file":"502-847554.png","id":502},"9a7749":{"file":"503-9a7749.png","id":503},"796044":{"file":"504-796044.png","id":504},"6a584a":{"file":"505-6a584a.png","id":505},"434947":{"file":"506-434947.png","id":506},"42423c":{"file":"507-42423c.png","id":507},"464741":{"file":"508-464741.png","id":508},"788475":{"file":"509-788475.png","id":509},"7d8075":{"file":"510-7d8075.png","id":510},"a15c26":{"file":"511-a15c26.png","id":511},"905924":{"file":"512-905924.png","id":512},"906a3b":{"file":"513-906a3b.png","id":513},"997c9b":{"file":"514-997c9b.png","id":514},"a6989e":{"file":"515-a6989e.png","id":515},"a5978c":{"file":"516-a5978c.png","id":516},"9d8e86":{"file":"517-9d8e86.png","id":517},"626169":{"file":"518-626169.png","id":518},"5e5d65":{"file":"519-5e5d65.png","id":519},"454446":{"file":"520-454446.png","id":520},"7d6646":{"file":"521-7d6646.png","id":521},"8e7145":{"file":"522-8e7145.png","id":522},"785f4c":{"file":"523-785f4c.png","id":523},"887651":{"file":"524-887651.png","id":524},"6f6450":{"file":"525-6f6450.png","id":525},"373e39":{"file":"527-373e39.png","id":527},"434942":{"file":"528-434942.png","id":528},"6f7062":{"file":"529-6f7062.png","id":529},"65725c":{"file":"530-65725c.png","id":530},"8f6329":{"file":"531-8f6329.png","id":531},"a56227":{"file":"532-a56227.png","id":532},"65596d":{"file":"533-65596d.png","id":533},"a78ea1":{"file":"534-a78ea1.png","id":534},"9998b7":{"file":"535-9998b7.png","id":535},"a7a39e":{"file":"536-a7a39e.png","id":536},"8f8a8e":{"file":"537-8f8a8e.png","id":537},"635e65":{"file":"538-635e65.png","id":538},"504a4a":{"file":"539-504a4a.png","id":539},"3d3e42":{"file":"540-3d3e42.png","id":540},"7b6244":{"file":"541-7b6244.png","id":541},"6e5840":{"file":"542-6e5840.png","id":542},"624d35":{"file":"543-624d35.png","id":543},"473e30":{"file":"544-473e30.png","id":544},"493922":{"file":"545-493922.png","id":545},"5c5444":{"file":"546-5c5444.png","id":546},"413d32":{"file":"547-413d32.png","id":547},"4e4d3e":{"file":"548-4e4d3e.png","id":548},"a5a497":{"file":"549-a5a497.png","id":549},"878a79":{"file":"550-878a79.png","id":550},"494036":{"file":"551-494036.png","id":551},"493e55":{"file":"552-493e55.png","id":552},"574768":{"file":"553-574768.png","id":553},"6a6684":{"file":"554-6a6684.png","id":554},"8a888b":{"file":"555-8a888b.png","id":555},"63646e":{"file":"556-63646e.png","id":556},"464543":{"file":"557-464543.png","id":557},"403f3f":{"file":"558-403f3f.png","id":558},"42424b":{"file":"559-42424b.png","id":559},"333134":{"file":"560-333134.png","id":560},"655139":{"file":"561-655139.png","id":561},"625038":{"file":"562-625038.png","id":562},"4a4332":{"file":"563-4a4332.png","id":563},"4e3f26":{"file":"564-4e3f26.png","id":564},"765b2f":{"file":"565-765b2f.png","id":565},"5f5949":{"file":"566-5f5949.png","id":566},"675d50":{"file":"567-675d50.png","id":567},"78756c":{"file":"568-78756c.png","id":568},"d0ad9e":{"file":"569-d0ad9e.png","id":569},"b4a087":{"file":"570-b4a087.png","id":570},"44384c":{"file":"571-44384c.png","id":571},"513d48":{"file":"572-513d48.png","id":572},"5a4e64":{"file":"573-5a4e64.png","id":573},"ccb4a9":{"file":"574-ccb4a9.png","id":574},"b1a3a2":{"file":"575-b1a3a2.png","id":575},"777379":{"file":"576-777379.png","id":576},"393936":{"file":"577-393936.png","id":577},"3b3745":{"file":"578-3b3745.png","id":578},"4c464d":{"file":"579-4c464d.png","id":579},"141416":{"file":"580-141416.png","id":580},"4c4130":{"file":"581-4c4130.png","id":581},"322e25":{"file":"582-322e25.png","id":582},"4e3c26":{"file":"583-4e3c26.png","id":583},"6d5332":{"file":"584-6d5332.png","id":584},"83662d":{"file":"585-83662d.png","id":585},"716960":{"file":"586-716960.png","id":586},"746e58":{"file":"587-746e58.png","id":587},"beb09d":{"file":"588-beb09d.png","id":588},"c5b2a4":{"file":"589-c5b2a4.png","id":589},"ccb7a4":{"file":"590-ccb7a4.png","id":590},"392e3f":{"file":"591-392e3f.png","id":591},"533b48":{"file":"592-533b48.png","id":592},"a4a2af":{"file":"593-a4a2af.png","id":593},"b3a3a3":{"file":"594-b3a3a3.png","id":594},"726d71":{"file":"595-726d71.png","id":595},"585a5e":{"file":"596-585a5e.png","id":596},"313036":{"file":"597-313036.png","id":597},"2b2a2d":{"file":"598-2b2a2d.png","id":598},"141718":{"file":"599-141718.png","id":599},"131617":{"file":"600-131617.png","id":600}}'; $sw = json_decode($sw, true); foreach ($sw as $k => $v) { $bg = new Imagick(); $bg->newImage(100, 136, new ImagickPixel("#" . $k)); $bg->setimageformat('png'); $fl = new Imagick("img/ARS_300.png"); $fl->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0); $fl->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $fl->compositeimage(new Imagick("img/ARS_300.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA); $fl->scaleimage(0, 60); $fl->setimageformat("png"); $fl->setImageFileName("tom/" . $k . ".png"); $fl->setinterlacescheme(\Imagick::INTERLACE_PNG); $fl->writeimage(); $fl->destroy(); } exit; }
public function setBackground($file) { if (empty($this->pdf)) { die('Set layout before'); } if (!is_file($file)) { die('Incorect background file'); } $tmp = $this->getTmpFilePath('pdf'); $img = new Imagick($file); $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $img->setresolution(300, 300); $img->setimageformat('pdf'); $img->writeimage($tmp); $this->pdf->setSourceFile($tmp); $this->pdf->SetMargins(0, 0, 0, true); $tplIdx = $this->pdf->importPage(1); $this->pdf->useTemplate($tplIdx, null, null, 0, 0, true); $this->pdf->SetMargins(0, 0, 0, true); $this->pdf->setCellHeightRatio(1); $this->pdf->setCellPaddings(0, 0, 0, 0); $this->pdf->setCellMargins(1, 1, 1, 1); $this->pdf->SetAutoPageBreak(false); $this->pdf->SetPrintHeader(false); $this->pdf->SetPrintFooter(false); }
/** * * const GRAVITY_NORTHWEST = 1; * const GRAVITY_NORTH = 2; * const GRAVITY_NORTHEAST = 3; * const GRAVITY_WEST = 4; * const GRAVITY_CENTER = 5; * const GRAVITY_EAST = 6; * const GRAVITY_SOUTHWEST = 7; * const GRAVITY_SOUTH = 8; * const GRAVITY_SOUTHEAST = 9; */ public function renderImage() { $imagick = new \Imagick(realpath("../imagick/images/Biter_500.jpg")); $imagick->setGravity(\Imagick::GRAVITY_SOUTHEAST); $imagick->cropImage(400, 300, 0, 0); $imagick->setimageformat('png'); header("Content-Type: image/png"); echo $imagick->getImageBlob(); }
/** * Generates preview page for pdf file. * * @param string $pdfFilePath full path to pdf file. * * @param string $imageFormat format of image, that must be generated. * Param may be one of the supported by [[Imagick::setImageFormat()]]. * @link http://php.net/manual/en/imagick.setimageformat.php * * @return string generated image content. * * @throws Exception if Imagick class not found. */ public static function getPreview($pdfFilePath, $imageFormat = 'jpg') { if (!class_exists('Imagick', false)) { throw new Exception('Imagick class required for ' . __NAMESPACE__ . '\\PdfHelper.'); } $imagick = new Imagick(realpath($pdfFilePath)); $imagick->setimageformat($imageFormat); return (string) $imagick; }
public function property() { $im = new Imagick(); $im->newimage(50, 50, 'blue'); $im->setimageformat('jpg'); $im->setimageproperty('comment', 'rawr'); var_dump($im->getimageproperty('comment')); $im->writeimage(getcwd() . '/images/test/output.jpg'); echo '<br />' . var_dump($im->getimageproperty('comment')); echo '<img src="/images/test/output.jpg" /><br />'; $this->read(); }
protected static function convertPDF($file) { if ("%PDF-" === file_get_contents($file, null, null, 0, 5)) { // magic! if (class_exists('Imagick')) { $img = new \Imagick($file . '[0]'); $img->setimageformat("jpg"); $img->writeimage($file); } else { exec(sprintf('convert %s[0] %s', escapeshellarg($file), escapeshellarg($file . '.jpg'))); rename($file . '.jpg', $file); } } }
public function storeCover(BookInterface $book, $cover) { #/conifg/filesystems.php $ebook_path = "{$book->id}/Resources/Templates/ebook/cover.jpg"; $print_path = storage_path("books/{$book->id}/Resources/Templates/print"); Storage::disk('book_local')->put($ebook_path, File::get($cover)); Storage::disk('book_local')->put("{$book->id}/Resources/Templates/cover.jpg", File::get($cover)); if (!is_dir($print_path)) { mkdir($print_path, 0775, true); // argumento true criar pastas recursivamente } $img = new \Imagick($ebook_path); $img->setimageformat("pdf"); $img->writeimage($print_path . '/cover.pdf'); }
public function renderCustomImage() { $size = 200; $imagick1 = new \Imagick(); $imagick1->newPseudoImage($size, $size, 'gradient:black-white'); $arguments = array(9, -90); $imagick1->functionImage(\Imagick::FUNCTION_SINUSOID, $arguments); $imagick2 = new \Imagick(); $imagick2->newPseudoImage($size, $size, 'gradient:black-white'); $arguments = array(0.5, 0); $imagick2->functionImage(\Imagick::FUNCTION_SINUSOID, $arguments); $imagick1->compositeimage($imagick2, \Imagick::COMPOSITE_MULTIPLY, 0, 0); $imagick1->setimageformat('png'); header("Content-Type: image/png"); echo $imagick1->getImageBlob(); }
/** * * @param string $dishUrl * @param int $w Width of the Output Image * @param int $h Height of Output Image * @return string Path of genrated Image */ public function createBowl($dishUrl = null, $w = 140, $h = 0) { $bowl = new Imagick("tmpl/img/bowl.png"); $mask = new Imagick("tmpl/img/mask.png"); $dish = new Imagick($dishUrl); $dish->scaleimage($bowl->getimagewidth(), $bowl->getimageheight()); // Set As per bowl image $dish->compositeimage(new Imagick("tmpl/img/mask.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA); $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $bowl->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA); $bowl->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $bowl->setimageformat("jpg"); $bowl->setImageFileName($url = "img_tmp/" . $this->randomString(10) . "-GE.jpg"); // $bowl->setinterlacescheme(\Imagick::INTERLACE_PNG); $bowl->scaleimage($w, $h); $bowl->writeimage(); $bowl->destroy(); return $url; }
function createBowl($dishUrl = null, $w = 140, $h = 0) { $du = explode("/", $dishUrl); $du = explode(".", $du[count($du) - 1]); $uri = $du[count($du) - 2]; $bowl = new Imagick("img/bowl.png"); $mask = new Imagick("img/mask.png"); $dish = new Imagick($dishUrl); $dish->scaleimage($bowl->getimagewidth(), $bowl->getimageheight()); // Set As per bowl image $dish->compositeimage(new Imagick("img/mask.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA); $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $bowl->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA); $bowl->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $bowl->setimageformat("jpg"); $bowl->setImageFileName($url = "gen/" . $uri . ".jpg"); // $bowl->setinterlacescheme(\Imagick::INTERLACE_PNG); $bowl->scaleimage($w, $h); $bowl->writeimage(); $bowl->destroy(); return $url; }
public function createThali($dishArray = array(), $w = 140, $h = 0) { Configure::write('debug', 2); ini_set("max_execution_time", -1); $thali = new Imagick("tmpl/img/thali.png"); $mask_1 = new Imagick("tmpl/img/thali-mask1.png"); $mask_2 = new Imagick("tmpl/img/thali-mask2.png"); $mask_3 = new Imagick("tmpl/img/thali-mask3.png"); $mask_4 = new Imagick("tmpl/img/thali-mask4.png"); $mask_5 = new Imagick("tmpl/img/thali-mask5.png"); if (!is_array($dishArray)) { return false; } $mask_cnt = 0; foreach ($dishArray as $dish) { if ($mask_cnt > 4) { // Mask Locking (Modify if masks will be increased or decreased) break; } $dish = new Imagick($dish); if ($mask_cnt + 1 == 5) { $dish = new Imagick("tmpl/dishes/rice.jpg"); // Fixed Rice for Mask No. 1 } $dish->scaleimage($thali->getimagewidth(), $thali->getimageheight()); // Set As per bowl image $dish->compositeimage(new Imagick("tmpl/img/thali-mask" . ($mask_cnt + 1) . ".png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA); $dish->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $thali->compositeimage($dish, \Imagick::COMPOSITE_ATOP, 0, 0, Imagick::CHANNEL_ALPHA); $thali->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $mask_cnt++; } $thali->setimageformat("jpg"); $thali->setImageFileName($url = "files/thali_images/" . $this->randomString(6) . "-Thali.jpg"); // $thali->setinterlacescheme(\Imagick::INTERLACE_PNG); $thali->scaleimage($w, $h); $thali->writeimage(); $thali->destroy(); return $url; }
/** * Get the image resource. * * Throws exception when resource is null && sourcePath is not set || targetExtension is not set. * * @return \Imagick * @throws ChateauLeTapImageServerBundleLogicException */ public function getRessource() { if (null === $this->ressource) { $sourcePath = $this->getImagePath(); if (null === $sourcePath) { throw new ChateauLeTapImageServerBundleLogicException('Please set the source path of the image before using it...'); } $image = new \Imagick($sourcePath); $targetExtension = $this->getExtension(); if (null === $targetExtension) { throw new ChateauLeTapImageServerBundleLogicException('Please set the target extension of the image before using it...'); } $image->setimageformat($targetExtension); $this->ressource = $image; } return $this->ressource; }
private function genImgRunner($rugpngs, $colors = array(), $location = "files/temp/") { if (is_file($location . "runner.png")) { return $location; } ini_set("max_execution_time", -1); $layers = array(); $bg = null; foreach ($rugpngs as $rp) { if ($rp['type'] == "LAYER") { $layers[] = new Imagick($rp['path']); } else { $bg = new Imagick($rp['path']); } } if ($bg == NULL) { $bg = new Imagick(); $bg->newImage(910, 475, new ImagickPixel('none')); $bg->setimageformat('png'); } foreach ($layers as $layer) { //$layer->resizeImage(910, 475, Imagick::FILTER_LANCZOS, 1, TRUE); $layer->setimageformat("png"); } $bg->resizeImage($layer->getimagewidth(), $layer->getimageheight(), Imagick::FILTER_LANCZOS, 1, TRUE); $bg->setimageformat("png"); $cnt_a = 0; foreach ($layers as $layer) { $layer->paintopaqueimage(new ImagickPixel('#000'), $colors[$cnt_a], 900000); $bg->compositeimage($layer, \Imagick::COMPOSITE_MULTIPLY, 0, 0); $cnt_a++; $layer->destroy(); } $bg->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $bg = $this->getBgPresp($bg, 60); $rnd = new Imagick("files/templates/new/runner/angle.png"); $bg->scaleimage(0, $rnd->getimageheight()); $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0); $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $rnd->compositeimage(new Imagick("files/templates/new/runner/angle_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA); $rnd->setimageformat("png"); $rnd->setImageFileName($location . "runner.png"); $rnd->setinterlacescheme(\Imagick::INTERLACE_PNG); $rnd->scaleimage(733, 0); $rnd->writeimage(); $rnd->destroy(); $rnd = new Imagick("files/templates/new/runner/flip.png"); $bg->scaleimage(0, $rnd->getimageheight()); $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0); $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $rnd->compositeimage(new Imagick("files/templates/new/runner/flip_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA); $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $rnd->compositeimage(new Imagick("files/templates/new/runner/flip.png"), \Imagick::COMPOSITE_DSTOVER, 0, 0, Imagick::CHANNEL_ALPHA); $rnd->setimageformat("png"); $rnd->setImageFileName($location . "runner1.png"); $rnd->setinterlacescheme(\Imagick::INTERLACE_PNG); $rnd->scaleimage(733, 0); $rnd->writeimage(); $rnd->destroy(); $rnd = new Imagick("files/templates/new/runner/straight.png"); $bg->scaleimage($rnd->getimagewidth(), 0); $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 0); $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $rnd->compositeimage(new Imagick("files/templates/new/runner/straight_trim.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA); $rnd->setimageformat("png"); $rnd->setImageFileName($location . "runner2.png"); $rnd->setinterlacescheme(\Imagick::INTERLACE_PNG); $rnd->scaleimage(733, 0); $rnd->writeimage(); $rnd->destroy(); /* $rnd = new Imagick("files/templates/runner/runners-4.png"); $rnd->compositeimage($bg, \Imagick::COMPOSITE_MULTIPLY, 0, 200); $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $rnd->compositeimage(new Imagick("files/templates/runner/runners-4.png"), \Imagick::COMPOSITE_COPYOPACITY, 0, 0, Imagick::CHANNEL_ALPHA); $rnd->mergeimagelayers(Imagick::LAYERMETHOD_COALESCE); $rnd->compositeimage(new Imagick("files/templates/runner/runners-5.png"), \Imagick::COMPOSITE_DEFAULT, 0, 0, Imagick::CHANNEL_ALPHA); $rnd->setimageformat("png"); $rnd->setImageFileName($location . "runner3.png"); $rnd->writeimage(); $rnd->destroy(); */ return $location; }
public function WritedataImage() { parent::setimageformat($this->format); parent::writeimage($this->save_to, false); }
/** * 合并两张图片(把图二合并到图一来) (ImageMagick 有个奇怪的问题,第一次运行会有点慢) * TODO GIF动画 * @param string $onePath * 需要合并的图片一 * @param string $twoPath * 需要合并的图片二 * @param string $dstPath * 合并后的保存地址 * @param integer $x * 合并坐标轴x * @param integer $y * 合并坐标轴y * @return boolean */ public function join($onePath, $twoPath, $dstPath, $x = 0, $y = 0) { $im1 = new Imagick(); $im1->readimage($onePath); $im2 = new Imagick($twoPath); $im2->setimageformat('png'); $composite = $im2->getImageCompose(); $im1->compositeimage($im2, $composite, $x, $y); $im2->destroy(); return $im1->writeImage($dstPath); }
/** * @param null $frameWidth * @param null $frameHeight * @throws Exception */ public function resize($frameWidth = null, $frameHeight = null) { if (empty($frameWidth) && empty($frameHeight)) { throw new Exception('Invalid image dimensions.'); } Varien_Profiler::start(__METHOD__); $imagick = $this->getImageMagick(); // calculate lacking dimension $origWidth = $imagick->getImageWidth(); $origHeight = $imagick->getImageHeight(); if ($this->keepFrame() === TRUE) { if (null === $frameWidth) { $frameWidth = $frameHeight; } elseif (null === $frameHeight) { $frameHeight = $frameWidth; } } else { if (null === $frameWidth) { $frameWidth = round($frameHeight * ($origWidth / $origHeight)); } elseif (null === $frameHeight) { $frameHeight = round($frameWidth * ($origHeight / $origWidth)); } } if ($this->_keepAspectRatio && $this->_constrainOnly) { if ($frameWidth >= $origWidth && $frameHeight >= $origHeight) { $frameWidth = $origWidth; $frameHeight = $origHeight; } } // Resize $imagick->setimageinterpolatemethod(imagick::INTERPOLATE_BICUBIC); $imagick->scaleimage($frameWidth, $frameHeight, true); // Fill desired canvas if ($this->keepFrame() === TRUE && $frameWidth != $origWidth && $frameHeight != $origHeight) { $composite = new Imagick(); $color = $this->_backgroundColor; if ($color && is_array($color) && count($color) == 3) { $bgColor = new ImagickPixel('rgb(' . implode(',', $color) . ')'); } else { $bgColor = new ImagickPixel('white'); } $composite->newimage($frameWidth, $frameHeight, $bgColor); $composite->setimageformat($imagick->getimageformat()); $composite->setimagecolorspace($imagick->getimagecolorspace()); $dstX = floor(($frameWidth - $imagick->getimagewidth()) / 2); $dstY = floor(($frameHeight - $imagick->getimageheight()) / 2); $composite->compositeimage($imagick, Imagick::COMPOSITE_OVER, $dstX, $dstY); $this->_imageHandler = $composite; $imagick->clear(); $imagick->destroy(); } Varien_Profiler::stop(__METHOD__); }
public function test() { // $rgb_arr = sscanf('rgb(243, 243, 243)', "rgb(%d, %d, %d)"); // print_r($this->rgbToCmyk($rgb_arr[0], $rgb_arr[1], $rgb_arr[2])); // exit(); // $img = new Imagick('test.jpg'); $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $img->setresolution(300, 300); $img->setimageformat('pdf'); $img->writeimage('test.pdf'); include_once APPPATH . 'libraries/tcpdf/tcpdf.php'; include_once APPPATH . 'libraries/tcpdf/fpdi.php'; // создаём лист $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false); $pdf->AddPage('L'); // загрузим ранее сохранённый шаблон $pdf->setSourceFile('test.pdf'); $pdf->SetMargins(0, 0, 0, true); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx, null, null, 0, 0, true); // установим опции для pdf $pdf->SetMargins(0, 0, 0, true); $pdf->setCellHeightRatio(1); $pdf->setCellPaddings(0, 0, 0, 0); $pdf->setCellMargins(1, 1, 1, 1); $pdf->SetAutoPageBreak(false); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $pdf->Image('qwe.png', 30, 30, 20, '', '', '', '', false, 300); $pdf->SetTextColor(0, 0, 0, 100); $pdf->SetFont('helvetica', 'BI', 10, '', 'false'); $pdf->Text(12, 9, 'Black CMYK'); $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/uploads/fynal.pdf', 'F'); $im = new Imagick(); $im->setResolution(300, 300); $im->readimage('uploads/fynal.pdf[0]'); $im->setImageFormat('jpeg'); $im->resizeimage(538, 360, Imagick::FILTER_LANCZOS, 1); $im->writeImage('uploads/fynal.jpg'); $im->clear(); $im->destroy(); // include_once APPPATH . 'libraries/drawer.php'; // // $drawer = new Drawer(); // $drawer->init(); // $drawer->setLayout(); // $drawer->setBackground('test.jpg'); // $drawer->drawImage('test.jpg', 10, 10, 30); // $drawer->drawText('Maxim', 10, 10, 'TimesNewRoman', 20, 'rgb(77, 77, 77)'); // $drawer->savePdf($_SERVER['DOCUMENT_ROOT'] . '/1.pdf'); // $drawer->makePreview($_SERVER['DOCUMENT_ROOT'] . '/1.pdf', $_SERVER['DOCUMENT_ROOT'] . '/1.jpg'); }
public function custom_design() { $config['upload_path'] = 'uploads/redactor'; $config['allowed_types'] = 'png|jpg|gif|pdf|tif|tiff'; $config['max_size'] = '10000'; $config['encrypt_name'] = true; $config['max_width'] = 1100; $config['max_height'] = 730; $this->load->library('upload', $config); if ($this->upload->do_upload()) { $file = $this->upload->data(); $faceMacket = 'uploads/redactor/' . $file['raw_name'] . '.jpg'; $img = new Imagick($file['full_path']); $img->flattenimages(); $img->setimageformat('jpg'); $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $img->writeimage($faceMacket); $this->db->insert('designs', array('product_id' => NULL, 'face' => $faceMacket, 'back' => '', 'type' => 'user')); $design_id = $this->db->insert_id(); exit(json_encode(array('error' => '', 'design_id' => $design_id))); } else { exit(json_encode(array('error' => $this->upload->display_errors(' ', ' ')))); } }
public function saveLogo($logoSpecs) { try { $logoName = md5(microtime(true) . uniqid(microtime(true))); $logoPath = ROOT_PATH . '/uploads/logos/' . $logoName . '/'; mkdir($logoPath, 0777); chmod($logoPath, 0777); $image = new \Imagick($logoSpecs['tmp_name']); $saveLogoPath = $logoPath . $logoName . '.png'; $image->setImageBackgroundColor('transparent'); $image->stripimage(); $image->setimageformat('png'); $image->writeImage($saveLogoPath); $image->destroy(); $image->clear(); // convert to paa $this->convert($saveLogoPath); return $logoName; } catch (\Exception $e) { return false; } return false; }
/** * Converts this attachment into a JPEG if ir is an image. */ public function convertToPNG() { if ($this->getAttachmentType() != self::ATTACHMENT_TYPE_IMAGE) { return; } $imagick = new Imagick(); $imagick->readimage(self::getStoragePath($this->getAttachmentId())); $imagick->setimageformat('png'); $imagick->writeimage(); }
public function exifRotate($inputFile, $inputType, $outputFile) { $exif = array(); //Compatible with XF 1.3 as it has method transformByExif $transforms = array(2 => 'flip-h', 3 => 180, 4 => 'flip-v', 5 => 'transpose', 6 => 90, 7 => 'transverse', 8 => 270); if (function_exists('exif_read_data')) { $exif = @exif_read_data($inputFile, 0); } if (isset($exif['Orientation']) && isset($transforms[$exif['Orientation']])) { $transform = $transforms[$exif['Orientation']]; $image = XenForo_Image_Abstract::createFromFile($inputFile, $inputType); if ($image && is_callable(array($image, 'transformByExif'))) { $image->transformByExif($exif['Orientation']); $image->output($inputType, $outputFile, 100); } elseif (is_int($transform)) { //TODO: Refactor code. if (XenForo_Application::getOptions()->imageLibrary['class'] === 'imPecl') { $class = new Imagick($inputFile); foreach ($class->coalesceImages() as $frame) { $frame->rotateImage(new ImagickPixel('none'), $transform); } $class->setimageformat(self::$extensionMap[$inputType]); $class->writeImages($outputFile, true); $class->destroy(); } else { $gd = $this->createImageFromFile($inputFile, $inputType); if ($gd) { $rotate = imagerotate($gd, $transform * -1, imageColorAllocateAlpha($gd, 0, 0, 0, 127)); $this->outputImage($rotate, $inputType, $outputFile); imagedestroy($rotate); imagedestroy($gd); } } } unset($image); } }
public function save_design() { if ($this->input->post('mode') == 'edit') { $this->db->delete('designs', array('id' => $this->input->post('design_id'))); } $faceMacket = str_replace('http://klever.media/', '', $this->input->post('faceMacket')); $backMacket = str_replace('http://klever.media/', '', $this->input->post('backMacket')); $face = $this->input->post('face'); $back = $this->input->post('back'); // get all fonts $query = $this->db->get('fonts'); $fonts = array(); foreach ($query->result() as $font) { $fonts[$font->family] = $font->source; } // generate pdf face template name and preview name $face_pdf = 'uploads/redactor/face_' . md5(microtime(true)) . '.pdf'; $face_preview = 'uploads/redactor/face_' . md5(microtime(true)) . '.jpg'; // convert face image to pdf $img = new Imagick($faceMacket); $img->setresolution(300, 300); $img->setcolorspace(Imagick::COLORSPACE_CMYK); $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $img->setimageformat('pdf'); $img->writeimage($face_pdf); // include TCPDF ana FPDI include_once APPPATH . 'libraries/tcpdf/tcpdf.php'; include_once APPPATH . 'libraries/tcpdf/fpdi.php'; include_once APPPATH . 'libraries/tcpdf/include/tcpdf_fonts.php'; $fontMaker = new TCPDF_FONTS(); // создаём лист $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false); $pdf->SetMargins(0, 0, 0, true); $pdf->AddPage('L'); // загрузим ранее сохранённый шаблон $pdf->setSourceFile($face_pdf); $pdf->SetMargins(0, 0, 0, true); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx, null, null, 0, 0, true); // установим опции для pdf $pdf->setCellHeightRatio(1); $pdf->setCellPaddings(0, 0, 0, 0); $pdf->setCellMargins(0, 0, 0, 0); $pdf->SetAutoPageBreak(false, 0); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); if (!empty($face)) { // отрисуем сначала изображения лица foreach ($face as $item) { if ($item['type'] == 'image') { $pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300); } } // потом текст на лице foreach ($face as $item) { if ($item['type'] == 'text') { $cmyk = $this->rgbToCmyk($item['color']); $pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100); // set font $tcpdfFont = $fontMaker->addTTFfont(realpath('fonts/redactor/' . $fonts[$item['font']])); $pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false'); $pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false); } } } // сохраним пдф лица $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf, 'F'); // сделаем превью для пользователя $im = new Imagick(); $im->setResolution(300, 300); $im->readimage($face_pdf . '[0]'); $im->flattenimages(); $im->setImageFormat('jpg'); $im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $im->writeImage($face_preview); $im->clear(); $im->destroy(); //exec('$ convert ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf . ' ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_preview); // есть ли оборот if (!empty($backMacket)) { // generate pdf back template name and preview name $back_pdf = 'uploads/redactor/back_' . md5(microtime(true)) . '.pdf'; $back_preview = 'uploads/redactor/back_' . md5(microtime(true)) . '.jpg'; // convert back image to pdf $img = new Imagick($backMacket); $img->setresolution(300, 300); $img->setcolorspace(Imagick::COLORSPACE_CMYK); $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $img->setimageformat('pdf'); $img->writeimage($back_pdf); // создаём лист $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false); $pdf->AddPage('L'); // загрузим ранее сохранённый шаблон $pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf); $pdf->SetMargins(0, 0, 0, true); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx, null, null, 0, 0, true); // установим опции для pdf $pdf->SetMargins(0, 0, 0, true); $pdf->setCellHeightRatio(1); $pdf->setCellPaddings(0, 0, 0, 0); $pdf->setCellMargins(1, 1, 1, 1); $pdf->SetAutoPageBreak(false); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); if (!empty($back)) { // отрисуем сначала изображения оборота foreach ($back as $item) { if ($item['type'] == 'image') { $pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300); } } // потом текст на обороте foreach ($back as $item) { if ($item['type'] == 'text') { $cmyk = $this->rgbToCmyk($item['color']); $pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100); // set font $tcpdfFont = $fontMaker->addTTFfont($_SERVER['DOCUMENT_ROOT'] . '/fonts/redactor/' . $fonts[$item['font']]); $pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false'); $pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false); } } } // сохраним пдф оборота $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf, 'F'); // сделаем превью для пользователя $im = new Imagick(); $im->setResolution(300, 300); $im->readimage($back_pdf . '[0]'); $im->setImageFormat('jpg'); $im->flattenimages(); $im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $im->writeImage($back_preview); $im->clear(); $im->destroy(); } $this->db->insert('products', array('name' => 'cards_pvc', 'tiraj' => 100, 'weight' => 0.5, 'price' => 0.49, 'cost' => 49, 'macket' => 'my_macket')); $product_id = $this->db->insert_id(); $this->db->insert('designs', array('product_id' => $product_id, 'theme_id' => $this->input->post('theme'), 'face_background' => $faceMacket, 'back_background' => empty($backMacket) ? NULL : $backMacket, 'face' => $face_preview, 'back' => empty($back_preview) ? '' : $back_preview, 'type' => 'system')); $design_id = $this->db->insert_id(); $options = array(); if (!empty($face)) { foreach ($face as $item) { if ($item['type'] == 'text') { $options[] = array('design_id' => $design_id, 'type' => 'text', 'front' => 'face', 'top' => $item['top'], 'left' => $item['left'], 'width' => NULL, 'height' => NULL, 'content' => $item['content'], 'font' => $item['font'], 'color' => $item['color'], 'size' => $item['size']); } else { $options[] = array('design_id' => $design_id, 'type' => 'image', 'front' => 'face', 'top' => $item['top'], 'left' => $item['left'], 'width' => $item['width'], 'height' => $item['height'], 'content' => $item['content'], 'font' => NULL, 'color' => NULL, 'size' => NULL); } } } if (!empty($back)) { foreach ($back as $item) { if ($item['type'] == 'text') { $options[] = array('design_id' => $design_id, 'type' => 'text', 'front' => 'back', 'top' => $item['top'], 'left' => $item['left'], 'width' => NULL, 'height' => NULL, 'content' => $item['content'], 'font' => $item['font'], 'color' => $item['color'], 'size' => $item['size']); } else { $options[] = array('design_id' => $design_id, 'type' => 'image', 'front' => 'back', 'top' => $item['top'], 'left' => $item['left'], 'width' => $item['width'], 'height' => $item['height'], 'content' => $item['content'], 'font' => NULL, 'color' => NULL, 'size' => NULL); } } } if (count($options) > 0) { $this->db->insert_batch('design_options', $options); } echo 'OK'; }
/** * @param null $frameWidth * @param null $frameHeight * @throws Exception */ public function resize($frameWidth = null, $frameHeight = null) { if (empty($frameWidth) && empty($frameHeight)) { throw new Exception('Invalid image dimensions.'); } Varien_Profiler::start(__METHOD__); $imagick = $this->getImageMagick(); // calculate lacking dimension $origWidth = $imagick->getImageWidth(); $origHeight = $imagick->getImageHeight(); if ($this->keepFrame() === TRUE) { if (null === $frameWidth) { $frameWidth = $frameHeight; } elseif (null === $frameHeight) { $frameHeight = $frameWidth; } } else { if (null === $frameWidth) { $frameWidth = round($frameHeight * ($origWidth / $origHeight)); } elseif (null === $frameHeight) { $frameHeight = round($frameWidth * ($origHeight / $origWidth)); } } if ($this->_keepAspectRatio && $this->_constrainOnly) { if ($frameWidth >= $origWidth && $frameHeight >= $origHeight) { $frameWidth = $origWidth; $frameHeight = $origHeight; } } // Resize $imagick->setimageinterpolatemethod(imagick::INTERPOLATE_BICUBIC); $imagick->scaleimage($frameWidth, $frameHeight, true); // Fill desired canvas if ($this->keepFrame() === TRUE && $frameWidth != $origWidth && $frameHeight != $origHeight) { $composite = new Imagick(); $color = $this->_backgroundColor; if ($color && is_array($color) && count($color) == 3) { $bgColor = new ImagickPixel('rgb(' . implode(',', $color) . ')'); } else { $bgColor = new ImagickPixel('white'); } $composite->newimage($frameWidth, $frameHeight, $bgColor); $composite->setimageformat($imagick->getimageformat()); if ($imagick->getimagecolorspace() == Imagick::COLORSPACE_CMYK) { $profiles = $imagick->getimageprofiles('*', false); // we're only interested if ICC profile(s) exist $has_icc_profile = array_search('icc', $profiles) !== false; // if it doesnt have a CMYK ICC profile, we add one if ($has_icc_profile === false) { $icc_cmyk = file_get_contents(__DIR__ . '/icc_profiles/USWebUncoated.icc'); $imagick->profileImage('icc', $icc_cmyk); unset($icc_cmyk); } // then we add an RGB profile $icc_rgb = file_get_contents(__DIR__ . '/icc_profiles/sRGB.icc'); $imagick->profileImage('icc', $icc_rgb); unset($icc_rgb); $imagick->setimagecolorspace(Imagick::COLORSPACE_SRGB); } $composite->setimagecolorspace($imagick->getimagecolorspace()); $dstX = floor(($frameWidth - $imagick->getimagewidth()) / 2); $dstY = floor(($frameHeight - $imagick->getimageheight()) / 2); $composite->compositeimage($imagick, Imagick::COMPOSITE_OVER, $dstX, $dstY); $this->_imageHandler = $composite; $imagick->clear(); $imagick->destroy(); } $this->refreshImageDimensions(); Varien_Profiler::stop(__METHOD__); }
<?php $allFiles = array_filter(scandir(__DIR__), function ($v) { return substr(strtolower($v), -4) == '.bmp'; }); $allFilesCount = count($allFiles); if (!$allFilesCount) { echo 'No bmp files were found.', PHP_EOL; exit; } $imagick = new Imagick(); echo 'process ', $allFilesCount, ' images', PHP_EOL; $i = 0; foreach ($allFiles as $filename) { $path = __DIR__ . '/' . $filename; $imagick->readImage($path); $imagick->setimageformat('png'); $imagick->transparentPaintImage('rgb(0, 255, 255)', 0.0, 0, false); $imagick->writeImage(substr($path, 0, -4) . '.png'); $imagick->clear(); unlink($path); echo 'processed ', ++$i, ' of ', $allFilesCount, ' files...', PHP_EOL; } echo 'All files were processed', PHP_EOL; $imagick->destroy();
public function renderImageArcsin() { //Example Imagick::functionImage ArcSin $imagick = new \Imagick(); $imagick->newPseudoImage(500, 500, 'gradient:black-white'); $arguments = array($this->control->getFirstTerm()); $secondTerm = $this->control->getSecondTerm(); $thirdTerm = $this->control->getThirdTerm(); $fourthTerm = $this->control->getFourthTerm(); if (strlen($secondTerm)) { $arguments[] = $secondTerm; if (strlen($thirdTerm)) { $arguments[] = $thirdTerm; if (strlen($fourthTerm)) { $arguments[] = $fourthTerm; } } } $imagick->functionImage(\Imagick::FUNCTION_ARCSIN, $arguments); $imagick->setimageformat('png'); analyzeImage($imagick, 512, 256); //Example end }
header('Content-Disposition: attachment; filename="shield.png"'); header('Content-Type: image/png'); echo $im->getimageblob(); break; } } else { switch ($options['outputFormat']) { case 'jpg': $im = new Imagick(); $im->readimageblob($output); $im->setimageformat('jpeg'); $im->setimagecompressionquality(90); // $im->scaleimage(1000,1200); header('Content-Type: image/jpg'); echo $im->getimageblob(); break; case 'png': $im = new Imagick(); $im->readimageblob($output); $im->setimageformat('png'); // $im->scaleimage(1000,1200); header('Content-Type: image/png'); echo $im->getimageblob(); break; default: case 'svg': header('Content-Type: text/xml; charset=utf-8'); echo $output; break; } }
public function logoFileAction() { $squadID = $this->params('id', null); $squadReposiory = $this->getEntityManager()->getRepository('Frontend\\Squads\\Entity\\Squad'); /** @var Squad $squad */ $squad = $squadReposiory->findOneBy(array('privateID' => $squadID)); if (!$squad) { $response = $this->getResponse(); $response->setStatusCode(404); $response->setContent(''); return $response; } $squadImageService = $this->getServiceLocator()->get('SquadImageService'); $squadLogoPath = $squadImageService->getServerSquadLogo($squad); if (!$squadLogoPath) { $response = $this->getResponse(); $response->setStatusCode(404); $response->setContent(''); return $response; } $response = $this->getResponse(); if ($response instanceof Response) { $headers = $this->response->getHeaders(); $headers->addHeaderLine('Content-Type', 'image/plain'); } if ($squad->getSquadLogoPaa()) { // return paa header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($squad->getSquadLogoPaa())); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize(ROOT_PATH . $squad->getSquadLogoPaa())); ob_clean(); flush(); readfile(ROOT_PATH . $squad->getSquadLogoPaa()); die; } // return normal image header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($squad->getSquadLogo())); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize(ROOT_PATH . $squad->getSquadLogo())); ob_clean(); flush(); $image = new \Imagick(ROOT_PATH . $squad->getSquadLogo()); $image->setImageBackgroundColor('white'); $image->setimageformat('jpg'); echo $image; die; }
/** * Abstract method that will return an image resource. * Throws exception when: * - $sourceImage ==== null && * - Source path is not set. || * - The target extension is not set. * * @param \Imagick|null $sourceImage If provided will apply effects on this resource * @param array $extraParameters Contain extraParameters. * * @return \Imagick * @throws ChateauLeTapImageServerBundleLogicException */ public function run($sourceImage = null, array $extraParameters = null) { $image = null; if (null === $sourceImage) { $sourcePath = $this->getSourcePath(); if (null === $sourcePath) { throw new ChateauLeTapImageServerBundleLogicException('Please set the source path of the image before using it...'); } $image = new \Imagick($sourcePath); $targetExtension = $this->getTargetExtension(); if (null === $targetExtension) { throw new ChateauLeTapImageServerBundleLogicException('Please set the target extension of the image before using it...'); } $image->setimageformat($targetExtension); } else { $image = $sourceImage; } return $image; }